-
1. Re: transaction propagation from client to the stateless session bean
mmusgrov Oct 29, 2012 6:58 AM (in response to rohanemmanuel)The example bundled with the article (https://community.jboss.org/wiki/TransactionPropagationWithJBoss) does what you are trying to do. In what ways does your example differ from the one in the article. Have you managed to get the one in the article working. We will need a bit more context/informaion to give you any useful feedback.
-
2. Re: transaction propagation from client to the stateless session bean
rohanemmanuel Oct 29, 2012 7:41 AM (in response to mmusgrov)Thanks for the quick reply Michael,
i'm using JTA not JTS,
i do begin and commit in the clients as mentioned below
public static void main(String[] args) throws ClassNotFoundException, {
IProject bean = doLookup();
javax.transaction.UserTransaction utTransaction;
utTransaction = com.arjuna.ats.jta.UserTransaction.userTransaction();
utTransaction = (UserTransaction) tm.getTransaction();
System.out.println("sending message to the queue");
try {
utTransaction.begin();
..........
..................
and in the bean i have transaction attribute as follows:
@Stateless
@TransactionManagement(TransactionManagementType.CONTAINER)
@TransactionAttribute(TransactionAttributeType.REQUIRED)
public class ProjectBean implements IProject {
..............
.....
i want the transaction to be propagated from the client to the bean .thats not happening at present.
if you need anymore information, i'l be happy to provide..
-
3. Re: transaction propagation from client to the stateless session bean
mmusgrov Oct 29, 2012 8:06 AM (in response to rohanemmanuel)If session beans E and K are running in separate JBoss servers then you must use JTS to propagate the transaction. But if they are in the same server then JTA will be sufficient.
Do you get the transaction from the same server on which the session beans are running? How does bean E lookup bean K?
(In your pseudo code I see two different ways of obtaining a UserTransaction, which one are you actually using?).
To test that the transaction propagates from the client to bean E can you temporarily change TransactionAttributeType.REQUIRED to TransactionAttributeType.MANDATORY so that we will immediatly see that the transaction wasn't propaged since the server hosting bean E will report an exception.when your client invokes the bean. Simillary, to test that transaction propagates from bean E to K can you mark the target method on bean K as MANDATORY too.
-
4. Re: transaction propagation from client to the stateless session bean
rohanemmanuel Oct 29, 2012 8:18 AM (in response to mmusgrov)the beans E and K are running on the same server.
i'm using this:
utTransaction = com.arjuna.ats.jta.UserTransaction.userTransaction(); is this the correct way?
the getTransaction was a commented line..forgot to remove it..
i had already tried using the MANDATORY attribute on the bean , it fails with an exception , hence i wanted to know how to propagate the transaction from client to bean.
but the transaction is being propagated to the second bean , if i explicitly throw an exception in one of the beans , everything is being rolled back.
-
5. Re: transaction propagation from client to the stateless session bean
mmusgrov Oct 29, 2012 8:47 AM (in response to rohanemmanuel)utTransaction = com.arjuna.ats.jta.UserTransaction.userTransaction(); is this the correct way?
I would recommend that you follow what the article says (also don't forget that you need to be looking the section that applies to local JTA transactions as opposed to distributed JTS transactions). Perhaps I should create two articles one dedicated to JTA and the other to JTS, I will put it on my todo list.
So, try it the way the article says and if it's still failing then please can you see if you can get the example attached to the article working since it should be doing exactly what you need.