-
1. Re: WS-AT Single UserTransaction object
gytis Apr 14, 2014 10:40 AM (in response to anderruiz)Hello Ander,
yes XTS is thread safe. Even thought we do have a single instance of the UserTransaction class, it operates using the information available on the current thread (we use java.lang.ThreadLocal there).
Gytis
-
2. Re: Re: WS-AT Single UserTransaction object
anderruiz Apr 21, 2014 7:17 AM (in response to gytis)I'm a bit surprised because I don't understand how can UserTransaction be thread safe and have some errors I was(am) getting. I understand that:
UserTransaction t = UserTransactionFactory.userTransaction();
Fills UserTransaction object with the values required for the current thread but what happens if at the same moment another Thread invokes the same instruction?, what I think is that the first Thread will see the modifications of the second. Or am I missing something?
This is based on my observation, originally I was creating a UserTransaction object in the start of a task and using the same object to commit or rollback in the end. If in the meantime I was receiving a WS call I was creating a "new" UserTransaction and the original task was commiting the transaction for the WS instead of its own. I minimized the errors by calling UserTransaction.userTransaction before the commit but I could still have race conditions
-
3. Re: Re: WS-AT Single UserTransaction object
gytis Apr 22, 2014 8:54 AM (in response to anderruiz)To answer your question "what happens if at the same moment another Thread invokes the same instruction?":
UserTransaction object will always be the same for every thread. However, transaction information associated with the thread is different, based on the information received with WS request. Transaction context associated with the thread is handled by the context manager (narayana/XTS/WSTX/classes/com/arjuna/mwlabs/wst/at/remote/ContextManager.java at 4.17.13.Final · jbosstm/narayana · GitH…).
Second part of the message is not very clear to me. Could you provide the stack trace with an error message. And also clarify the scenario which is failing?
-
4. Re: WS-AT Single UserTransaction object
paul.robinson Apr 26, 2014 1:59 PM (in response to gytis)Ander,
I agree with Gytis, this does sound strange. Can you provide a simple reproducer so we can see it happening? This will make it a lot easier for us to fix or identify what you are doing wrong.
Paul
-
5. Re: WS-AT Single UserTransaction object
anderruiz Apr 28, 2014 3:33 AM (in response to paul.robinson)It may have been my own mistake, I'm testing it and will provide more information as soon as I have one conclusion