Announcement Announcement Module
Collapse
No announcement yet.
Transactions that span multiple web service calls Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Transactions that span multiple web service calls

    Hello all.

    I'm using Spring JtaTransactionManager to successfully use JBossTS JTA transaction manager to manage JTA distributed transactions in my web application.

    However, recently I have a new challenge to win: provide a way to allow the calling of many web services within the same transaction and commit at the end.

    The problem is that there's a strong relationship between the current thread and the current active transaction. Instead, in my case I would need to do something like that:

    1) a user calls a web service to login and he is assigned a token; a new transaction is associated with that token and immediately suspended
    3) a user calls a web service "operation1", providing the token: the transaction previously associated with that token is retrieved and resumed, the "operation1" is executed in that transaction context and the transaction is suspended again
    4) a user calls a web service "operation2", providing the token: the transaction associated with that token is retrieved again and resumed, the "operation2" is executed in that transaction context and the transaction is suspended again
    5) a user calls another web service to commit and logout, providing the token: the transaction associated with that token is retrieved again, resumed and finally committed

    The problem is that every step is a request-response cycle, so each could be executed in a different thread and I'm not sure that the JtaTransactionManager supports that.

    Moreover, the methods to suspend and resume a transaction are protected, so they cannot be called from the outside. They're even final, so I can't widen their visibility. Also org.springframework.transaction.support.AbstractPl atformTransactionManager.doGetTransaction() is protected and its result is needed to provide the input parameter for suspend.
    So, it seems like a use of the PlatformTransactionManager in this way is not supported and I fear that, even if I could hack the code to be able to call suspend(), it won't work. It seems to me that the suspension/resume support is limited to the implementation of the different propagation behaviours at transaction creation, which happens within the scope of an only thread.

    On the other hand I could try to to suspend/resume on the underlying JBossTS TransactionManager implementation used by the JtaTransactionManager. However, I'm not sure that this wouldn't cause problems to Spring: I mean, there is some code that is using the JtaTransactionManager + Spring infrastructure to start transactions and do work on the associated resources (i.e.: data sources), BUT there is some other code that bypasses the whole thing and suspends/resumes transactions without letting the JtaTransactionManager know. I fear this could lead to problems, especially with Spring transaction synchronizations.

    So, my question is: what is the correct approach to solve my problem? Do I have to give up and create atomic web service operations that do all the work I have to do in a single transaction?

    Thanks in advance,
    Mauro.

    BTW: I'm also experimenting with XTS, the JBossTS implementation of the WS-T, WS-AT and WS-C protocols, plus the transaction bridge between that and JTA. However, at some point in the code the problem would be the same: the XTS+bridge infrastructure will need to suspend and resume a transaction spanning multiple threads and this might happen without any notification to Spring. So I think that the core of the problem is the same.

  • #2
    Has anybody already faced this problem?

    Comment

    Working...
    X