I have a stateless session bean with a bean managed transaction. However, i would like to emulate the container managed approach of 'Required', ie if there is already a transaction in progress then 'join' it, otherwise start a new one.
How do i do that?
-
How do i emulate container managed 'Required'? (5 messages)
- Posted by: numberone skier
- Posted on: November 24 2004 22:57 EST
Threaded Messages (5)
- How do i emulate container managed 'Required'? by Deepam Gupta on November 26 2004 01:27 EST
- nice try... by numberone skier on November 28 2004 17:52 EST
-
set trans-attribute in ejb-jar.xml by Saurabh Siddharth on December 01 2004 01:21 EST
- sorry.. by Saurabh Siddharth on December 01 2004 01:23 EST
-
set trans-attribute in ejb-jar.xml by Saurabh Siddharth on December 01 2004 01:21 EST
- nice try... by numberone skier on November 28 2004 17:52 EST
- If you don't use CMT or CMP... by Guy Pardon on December 05 2004 05:22 EST
-
How do i emulate container managed 'Required'?[ Go to top ]
- Posted by: Deepam Gupta
- Posted on: November 26 2004 01:27 EST
- in response to numberone skier
SessionContext sessionContext = null;
public void setSessionContext(SessionContext sctx) {
this.sessionContext = sctx;
}
public void sampleMethod () {
UserTransaction ut = sessionContext.getUserTransaction();
int status = ut.getStatus();
if(status == Status.STATUS_NO_TRANSACTION) {
ut.begin();
...
ut.commit();
} else if (status == Status.STATUS_ACTIVE) {
...
}
}
Will this solve the problem -
nice try...[ Go to top ]
- Posted by: numberone skier
- Posted on: November 28 2004 17:52 EST
- in response to Deepam Gupta
Thanks for responding. i got excited when i saw your answer, but in the end it doesn't work (using WAS 5.1).
It never seems to 'join' the existing xaction (the status is never STATUS_ACTIVE).
I've been trying various things for a while now and am going to give up and try and get my requirements changed!
Thanks anyway. -
set trans-attribute in ejb-jar.xml[ Go to top ]
- Posted by: Saurabh Siddharth
- Posted on: December 01 2004 01:21 EST
- in response to numberone skier
in the ejb-jar.xml set the trans-attribute to required for your method eg if the method is tryThis(). I think this should help.
<assembly-descriptor>
<container-transaction>
<method>
<ejb-name>TryBean</ejb-name>
<method-name>tryThis</method-name>
</method>
<trans-attribute>Required</trans-attribute>
</container-transaction>
</assembly-descriptor> -
sorry..[ Go to top ]
- Posted by: Saurabh Siddharth
- Posted on: December 01 2004 01:23 EST
- in response to Saurabh Siddharth
plz ignore the above reply by me...mea culpa... -
If you don't use CMT or CMP...[ Go to top ]
- Posted by: Guy Pardon
- Posted on: December 05 2004 05:22 EST
- in response to numberone skier
Hi,
You could try to use the Atomikos Transactions product for this.
In particular, you can use Transactions to:
-integrate an external JTA implementation in your J2EE application server
-deploy XA-capable JDBC DataSources
-perform transactions over them with BMT
-in a J2EE server-independent way (it works on any J2EE container)
However, if you are using Websphere's CMT then this may not mix well. You would have similar problems then. Currently, we only support JBoss CMT.
If you're interested, feel free to check out http://www.atomikos.com for more information and download.
HTH,
Guy Pardon
The Transaction Processing Company