UserTransaction used by remote clients

classic Classic list List threaded Threaded
11 messages Options
Reply | Threaded
Open this post in threaded view
|

UserTransaction used by remote clients

Wolf-Dieter Fink
Is it possible to lookup and use UserTransaction from a remote-client as
in AS5?
Or is it planned for further release?

I neither found an open JIRA nor a documentation
(https://docs.jboss.org/author/display/AS71  Migration)

regards
Wolf
_______________________________________________
jboss-as7-dev mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/jboss-as7-dev
Reply | Threaded
Open this post in threaded view
|

Re: UserTransaction used by remote clients

David Lloyd-2
On 03/06/2012 11:17 AM, Wolf-Dieter Fink wrote:
> Is it possible to lookup and use UserTransaction from a remote-client as
> in AS5?
> Or is it planned for further release?

In AS 7, you can have a connection to more than one server at once.
Thus you have to specify which server node you want to talk to.  The
method you want is
org.jboss.ejb.client.EJBClient#getUserTransaction(String), where the
argument is the node name.  Note that your connection must already be
established at this point.

We do not presently have a way to pull a UserTransaction out of JNDI,
though that could be considered for an enhancement.

--
- DML
_______________________________________________
jboss-as7-dev mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/jboss-as7-dev
Reply | Threaded
Open this post in threaded view
|

Re: UserTransaction used by remote clients

Jason T. Greene
Another interesting thing you can also do is use Arjuna in Jta mode on the client and join local resources in the transaction as well.

Sent from my iPhone

On Mar 6, 2012, at 1:09 PM, "David M. Lloyd" <[hidden email]> wrote:

> On 03/06/2012 11:17 AM, Wolf-Dieter Fink wrote:
>> Is it possible to lookup and use UserTransaction from a remote-client as
>> in AS5?
>> Or is it planned for further release?
>
> In AS 7, you can have a connection to more than one server at once.
> Thus you have to specify which server node you want to talk to.  The
> method you want is
> org.jboss.ejb.client.EJBClient#getUserTransaction(String), where the
> argument is the node name.  Note that your connection must already be
> established at this point.
>
> We do not presently have a way to pull a UserTransaction out of JNDI,
> though that could be considered for an enhancement.
>
> --
> - DML
> _______________________________________________
> jboss-as7-dev mailing list
> [hidden email]
> https://lists.jboss.org/mailman/listinfo/jboss-as7-dev

_______________________________________________
jboss-as7-dev mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/jboss-as7-dev
Reply | Threaded
Open this post in threaded view
|

Re: UserTransaction used by remote clients

Wolf-Dieter Fink
In reply to this post by David Lloyd-2
=====   Regarding node-name.   =====
In standalone I supposed it is the name of jboss-ejb-client.properties
    remote.connection.default.host=localhost
But I have to set it by -Djboss.node.name=<>.
???  it is not possible to add a system-property to the standalone.xml for that, or do I something wrong with the system-property element in configuration???
??? What is the name in domain mode? Is the <server name="" ...> attribute for each defined server used???
??? Is it possible to see the node name with the management console???

The section for remote invoking EJB's note that a node name must be set unique, but I did not see any problem if I start two instances (same machine) without jboss.node.name?
Is here a default created?


====  UserTransaction  =====
If I do this in my client:
{code}
1:       UserTransaction uTx = EJBClient.getUserTransaction("Wolf");
2:      LOG.debug("UserTransaction ="+uTx);
3:      uTx.begin();
4:      LOG.debug("Tx.begin() ok");
5:      bmtSession.checkTransaction(); // call a SLSB to use Tx
6:      uTx.commit();
        LOG.debug("Tx.commit() ok");
{code}

Line 1 and 3 works nevertheless whether there is a server (with or without a correct node.name) or not. The line 5: will fail 'No EJB receiver with 'node.name'
If I remove getUserTransaction I can execute the code nevertheless whether a node name is set or not.

???  So I suppose the getUTx will attach the next EJB call to that server ???

If a server is available the commit will fail (also the EJB checkTransaction show the TxState=6 (NO-Tx)
java.lang.IllegalStateException: BaseTransaction.commit - ARJUNA016074: no transaction!
    at com.arjuna.ats.internal.jta.transaction.arjunacore.BaseTransaction.commit(BaseTransaction.java:113)
    at com.arjuna.ats.jbossatx.BaseTransactionManagerDelegate.commit(BaseTransactionManagerDelegate.java:75)
    at org.jboss.as.ejb3.remote.protocol.versionone.UserTransactionCommitTask.manageTransaction(UserTransactionCommitTask.java:47)
    at org.jboss.as.ejb3.remote.protocol.versionone.UserTransactionManagementTask.run(UserTransactionManagementTask.java:64)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
    at java.util.concurrent.FutureTask.run(FutureTask.java:166)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
    at java.lang.Thread.run(Thread.java:679)
    at org.jboss.threads.JBossThread.run(JBossThread.java:122)


??? My question what is wrong with my assumption or code???


- Wolf


On 03/06/2012 06:28 PM, David M. Lloyd wrote:
On 03/06/2012 11:17 AM, Wolf-Dieter Fink wrote:
Is it possible to lookup and use UserTransaction from a remote-client as
in AS5?
Or is it planned for further release?
In AS 7, you can have a connection to more than one server at once. 
Thus you have to specify which server node you want to talk to.  The 
method you want is 
org.jboss.ejb.client.EJBClient#getUserTransaction(String), where the 
argument is the node name.  Note that your connection must already be 
established at this point.

We do not presently have a way to pull a UserTransaction out of JNDI, 
though that could be considered for an enhancement.



_______________________________________________
jboss-as7-dev mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/jboss-as7-dev
Reply | Threaded
Open this post in threaded view
|

Re: UserTransaction used by remote clients

Wolf-Dieter Fink
In reply to this post by Jason T. Greene
On 03/07/2012 01:55 AM, Jason Greene wrote:
> Another interesting thing you can also do is use Arjuna in Jta mode on the client and join local resources in the transaction as well.
>
Is a how-to or documentation for that available?
_______________________________________________
jboss-as7-dev mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/jboss-as7-dev
Reply | Threaded
Open this post in threaded view
|

Re: UserTransaction used by remote clients

Jaikiran Pai
In reply to this post by Wolf-Dieter Fink
I haven't fully read this mail (just booting up), but I guess this
testcase will help you get started
https://github.com/jbossas/jboss-as/blob/master/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/ejb/remote/client/api/tx/EJBClientUserTransactionTestCase.java

-Jaikiran
On Thursday 08 March 2012 12:24 AM, Wolf-Dieter Fink wrote:

> =====   Regarding node-name.   =====
> In standalone I supposed it is the name of jboss-ejb-client.properties
>     remote.connection.*default*.host=localhost
> But I have to set it by -Djboss.node.name=<>.
> ???  it is not possible to add a system-property to the standalone.xml
> for that, or do I something wrong with the system-property element in
> configuration???
> ??? What is the name in domain mode? Is the <server name="" ...>
> attribute for each defined server used???
> ??? Is it possible to see the node name with the management console???
>
> The section for remote invoking EJB's note that a node name must be
> set unique, but I did not see any problem if I start two instances
> (same machine) without jboss.node.name?
> Is here a default created?
>
>
> ====  UserTransaction  =====
> If I do this in my client:
> {code}
> 1:       UserTransaction uTx = EJBClient.getUserTransaction("Wolf");
> 2:      LOG.debug("UserTransaction ="+uTx);
> 3:      uTx.begin();
> 4:      LOG.debug("Tx.begin() ok");
> 5:      bmtSession.checkTransaction(); // call a SLSB to use Tx
> 6:      uTx.commit();
>         LOG.debug("Tx.commit() ok");
> {code}
>
> Line 1 and 3 works nevertheless whether there is a server (with or
> without a correct node.name) or not. The line 5: will fail 'No EJB
> receiver with 'node.name'
> If I remove getUserTransaction I can execute the code nevertheless
> whether a node name is set or not.
>
> ???  So I suppose the getUTx will attach the next EJB call to that
> server ???
>
> If a server is available the commit will fail (also the EJB
> checkTransaction show the TxState=6 (NO-Tx)
> java.lang.IllegalStateException: BaseTransaction.commit -
> ARJUNA016074: no transaction!
>     at
> com.arjuna.ats.internal.jta.transaction.arjunacore.BaseTransaction.commit(BaseTransaction.java:113)
>     at
> com.arjuna.ats.jbossatx.BaseTransactionManagerDelegate.commit(BaseTransactionManagerDelegate.java:75)
>     at
> org.jboss.as.ejb3.remote.protocol.versionone.UserTransactionCommitTask.manageTransaction(UserTransactionCommitTask.java:47)
>     at
> org.jboss.as.ejb3.remote.protocol.versionone.UserTransactionManagementTask.run(UserTransactionManagementTask.java:64)
>     at
> java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
>     at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
>     at java.util.concurrent.FutureTask.run(FutureTask.java:166)
>     at
> java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
>     at
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
>     at java.lang.Thread.run(Thread.java:679)
>     at org.jboss.threads.JBossThread.run(JBossThread.java:122)
>
>
> ??? My question what is wrong with my assumption or code???
>
>
> - Wolf
>
>
> On 03/06/2012 06:28 PM, David M. Lloyd wrote:
>> On 03/06/2012 11:17 AM, Wolf-Dieter Fink wrote:
>>> Is it possible to lookup and use UserTransaction from a remote-client as
>>> in AS5?
>>> Or is it planned for further release?
>> In AS 7, you can have a connection to more than one server at once.
>> Thus you have to specify which server node you want to talk to.  The
>> method you want is
>> org.jboss.ejb.client.EJBClient#getUserTransaction(String), where the
>> argument is the node name.  Note that your connection must already be
>> established at this point.
>>
>> We do not presently have a way to pull a UserTransaction out of JNDI,
>> though that could be considered for an enhancement.
>>
>
>
>
> _______________________________________________
> jboss-as7-dev mailing list
> [hidden email]
> https://lists.jboss.org/mailman/listinfo/jboss-as7-dev

_______________________________________________
jboss-as7-dev mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/jboss-as7-dev
Reply | Threaded
Open this post in threaded view
|

Re: UserTransaction used by remote clients

Stuart Douglas
In reply to this post by Wolf-Dieter Fink

Part of the problem is this issue that we just discovered: https://issues.jboss.org/browse/AS7-4092, where empty transactions cannot be committed or rolled back. 

I am just testing a fix now.

Stuart

On 08/03/2012, at 5:54 AM, Wolf-Dieter Fink wrote:

=====   Regarding node-name.   =====
In standalone I supposed it is the name of jboss-ejb-client.properties
    remote.connection.default.host=localhost
But I have to set it by -Djboss.node.name=<>.
???  it is not possible to add a system-property to the standalone.xml for that, or do I something wrong with the system-property element in configuration???
??? What is the name in domain mode? Is the <server name="" ...> attribute for each defined server used???
??? Is it possible to see the node name with the management console???

The section for remote invoking EJB's note that a node name must be set unique, but I did not see any problem if I start two instances (same machine) without jboss.node.name?
Is here a default created?


====  UserTransaction  =====
If I do this in my client:
{code}
1:       UserTransaction uTx = EJBClient.getUserTransaction("Wolf");
2:      LOG.debug("UserTransaction ="+uTx);
3:      uTx.begin();
4:      LOG.debug("Tx.begin() ok");
5:      bmtSession.checkTransaction(); // call a SLSB to use Tx
6:      uTx.commit();
        LOG.debug("Tx.commit() ok");
{code}

Line 1 and 3 works nevertheless whether there is a server (with or without a correct node.name) or not. The line 5: will fail 'No EJB receiver with 'node.name'
If I remove getUserTransaction I can execute the code nevertheless whether a node name is set or not.

???  So I suppose the getUTx will attach the next EJB call to that server ???

If a server is available the commit will fail (also the EJB checkTransaction show the TxState=6 (NO-Tx)
java.lang.IllegalStateException: BaseTransaction.commit - ARJUNA016074: no transaction!
    at com.arjuna.ats.internal.jta.transaction.arjunacore.BaseTransaction.commit(BaseTransaction.java:113)
    at com.arjuna.ats.jbossatx.BaseTransactionManagerDelegate.commit(BaseTransactionManagerDelegate.java:75)
    at org.jboss.as.ejb3.remote.protocol.versionone.UserTransactionCommitTask.manageTransaction(UserTransactionCommitTask.java:47)
    at org.jboss.as.ejb3.remote.protocol.versionone.UserTransactionManagementTask.run(UserTransactionManagementTask.java:64)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
    at java.util.concurrent.FutureTask.run(FutureTask.java:166)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
    at java.lang.Thread.run(Thread.java:679)
    at org.jboss.threads.JBossThread.run(JBossThread.java:122)


??? My question what is wrong with my assumption or code???


- Wolf


On 03/06/2012 06:28 PM, David M. Lloyd wrote:
On 03/06/2012 11:17 AM, Wolf-Dieter Fink wrote:
Is it possible to lookup and use UserTransaction from a remote-client as
in AS5?
Or is it planned for further release?
In AS 7, you can have a connection to more than one server at once. 
Thus you have to specify which server node you want to talk to.  The 
method you want is 
org.jboss.ejb.client.EJBClient#getUserTransaction(String), where the 
argument is the node name.  Note that your connection must already be 
established at this point.

We do not presently have a way to pull a UserTransaction out of JNDI, 
though that could be considered for an enhancement.


_______________________________________________
jboss-as7-dev mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/jboss-as7-dev


_______________________________________________
jboss-as7-dev mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/jboss-as7-dev
Reply | Threaded
Open this post in threaded view
|

Re: UserTransaction used by remote clients

Jaikiran Pai
In reply to this post by Wolf-Dieter Fink
On Thursday 08 March 2012 12:24 AM, Wolf-Dieter Fink wrote:
> =====   Regarding node-name.   =====
> In standalone I supposed it is the name of jboss-ejb-client.properties
>     remote.connection.*default*.host=localhost
> But I have to set it by -Djboss.node.name=<>.

Note that the "default" remote.connection.default is _not_ the
jboss.node.name of the server. It's just some random name you use for
identifying connections within the properties file. The way you use it is:

remote.connections=foo

which will indicate that you have a connection configuration for a
connection named foo. Later in the properties file you'll have:

remote.connection.foo.host=bar

So here you are configuring a connection named foo and setting its host
property to bar. So the "foo" is any random name of your choice. It will
play no other role than identifying the connection configuration for
that connection. It has no relation with jboss.node.name system property
from the server side.

>
>
> The section for remote invoking EJB's note that a node name must be
> set unique, but I did not see any problem if I start two instances
> (same machine) without jboss.node.name?
> Is here a default created?
The problem is "hidden". If you have 2 or more instances on the same
machine and you don't use a unique jboss.node.name for each of these
instances and if your EJB client program lists both these servers within
the jboss-ejb-client.properties, then only one of them will be
registered within the EJB client context. The other registration will be
skipped because a EJB client context can't have more than 1 EJB receiver
with the same node name. So depending on your application deployments on
those instances, things may or may not work.


-Jaikiran
_______________________________________________
jboss-as7-dev mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/jboss-as7-dev
Reply | Threaded
Open this post in threaded view
|

Re: UserTransaction used by remote clients

Wolf-Dieter Fink
In reply to this post by David Lloyd-2
So far so good, after pulling last 7.1.1 SNAPSHOT most problems are gone.

I create a CMT-SLSB with all TxAttributes and check whether it can be
called (or not) if I have a client side UTx.
Everything works fine.

But with BMT-SLSB.
If I start the Tx at client and call a method the following code return
with FALSE:
{code}
@Stateless
@TransactionManagement(TransactionManagementType.BEAN)
public class BMTStatelessSessionBean implements BMTStatelessSession {
     private static final Logger LOGGER =
LoggerFactory.getLogger(BMTStatelessSessionBean.class);

     @Resource
     UserTransaction uTx;
     @Override
     public boolean checkTransaction() {

         try {
             if(uTx.getStatus() == Status.STATUS_ACTIVE) {
                 return true;
             }
             LOGGER.error("Transaction is not Active as expected! State
{}",uTx.getStatus());
         } catch (SystemException e) {
             LOGGER.error("Could not check Transaction!",e);
         }
         return false;
     }
{code}

Am I wrong? If I remember correct from my examples this should work in AS5.
Or is it a bug?

========================

Also a question about the lookup at client side.
In AS5 there is a JNDI lookup for UTx and SLSB/SFSB.
If UTx is started there is a configuration possibility to have a
TxSticky (Utx and bean calls are routed to the same instance as long as
the Tx is open).
This is without having any knowledge of the server's names!

@Jaikiran - might be a question for you
What about loadbalancing EJB calls? If I remember rightly this was
planned for 7.1.1.

@David
As you mentioned before should I open an enhancement JIRA for JNDI UTx
lookup?
I think it is important for customers.

- Wolf

On 03/06/2012 06:28 PM, David M. Lloyd wrote:

> On 03/06/2012 11:17 AM, Wolf-Dieter Fink wrote:
>> Is it possible to lookup and use UserTransaction from a remote-client as
>> in AS5?
>> Or is it planned for further release?
> In AS 7, you can have a connection to more than one server at once.
> Thus you have to specify which server node you want to talk to.  The
> method you want is
> org.jboss.ejb.client.EJBClient#getUserTransaction(String), where the
> argument is the node name.  Note that your connection must already be
> established at this point.
>
> We do not presently have a way to pull a UserTransaction out of JNDI,
> though that could be considered for an enhancement.
_______________________________________________
jboss-as7-dev mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/jboss-as7-dev
Reply | Threaded
Open this post in threaded view
|

Re: UserTransaction used by remote clients

Jaikiran Pai
Replies inline.

On Friday 09 March 2012 08:37 PM, Wolf-Dieter Fink wrote:

>
> But with BMT-SLSB.
> If I start the Tx at client and call a method the following code
> return with FALSE:
> {code}
> @Stateless
> @TransactionManagement(TransactionManagementType.BEAN)
> public class BMTStatelessSessionBean implements BMTStatelessSession {
> private static final Logger LOGGER =
> LoggerFactory.getLogger(BMTStatelessSessionBean.class);
>
> @Resource
> UserTransaction uTx;
> @Override
> public boolean checkTransaction() {
>
> try {
> if(uTx.getStatus() == Status.STATUS_ACTIVE) {
> return true;
> }
> LOGGER.error("Transaction is not Active as expected! State
> {}",uTx.getStatus());
> } catch (SystemException e) {
> LOGGER.error("Could not check Transaction!",e);
> }
> return false;
> }
> {code}
>
> Am I wrong? If I remember correct from my examples this should work in
> AS5.
> Or is it a bug?

The EJB 3.1 spec section 13.6.1 says this for BMT:
<quote>
The container must manage client invocations to an enterprise bean
instance with bean-managed transaction demarcation as follows. When a
client invokes a business method via one of the enterprise bean’s client
views, the container suspends any transaction that may be associated
with the client request...
</quote>
That section has much more details about how this is handled for SFSB
and SLSB.

>
> @Jaikiran - might be a question for you
> What about loadbalancing EJB calls? If I remember rightly this was
> planned for 7.1.1.
Load balancing is available for @Clustered beans as well as
non-clustered beans/servers. For @Clustered beans the load balancing can
be configured by setting the
remote.cluster.<cluster-name>.clusternodeselector property to point to
an implementation of the org.jboss.ejb.client.ClusterNodeSelector
interface. Or programatically, you set it on the
org.jboss.ejb.client.ClusterContext yourself.

For non-clustered beans, if multiple server instances/receivers within a
client context can serve the same deployment, then we use an
implementation of org.jboss.ejb.client.DeploymentNodeSelector to let
that selector decide the node. Currently this isn't configurable, but
will be in 1.1.x of ejb-client API. For 1.0.x the demand was to just
make sure that the invocation doesn't always end up on the same node.

P.S: I don't have the code open right now, so some of the property
names/class names might not be completely accurate.

-Jaikiran
_______________________________________________
jboss-as7-dev mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/jboss-as7-dev
Reply | Threaded
Open this post in threaded view
|

Re: UserTransaction used by remote clients

Jaikiran Pai
In reply to this post by Wolf-Dieter Fink
On Friday 09 March 2012 08:37 PM, Wolf-Dieter Fink wrote:
>
> Also a question about the lookup at client side.
> In AS5 there is a JNDI lookup for UTx and SLSB/SFSB.
> If UTx is started there is a configuration possibility to have a
> TxSticky (Utx and bean calls are routed to the same instance as long
> as the Tx is open).
> This is without having any knowledge of the server's names!
I am not aware of AS5 details on how this was made available. But I
guess you would specify the PROVIDER_URL as the node identifier isn't
it? So you would still be referring to the server except that instead of
a name you would be using the PROVIDER_URL.

-Jaikiran
_______________________________________________
jboss-as7-dev mailing list
[hidden email]
https://lists.jboss.org/mailman/listinfo/jboss-as7-dev