Results 1 to 7 of 7

Thread: Transaction Resuming

  1. #1
    Join Date
    Nov 2005
    Posts
    12

    Default Transaction Resuming

    Hi,

    I am using a JTATransactionManager to manage, create, suspend my transactions. I have a method, Method A, that calls another method, Method B, which itself calls another method, Method C. Method A creates a transaction, and Method B suspends the transaction while it is running. I want Method C to resume the same transaction that B suspended. Is this possible? Right now, Method C is forced to create a new transaction, because it does not see the suspended transaction. Or, is it that while Method B is active, the suspended transaction cannot be resumed. (We are using TransactionProxyFactoryBean to intercept our method calls and uses the transactions)

    Roshan

  2. #2
    Join Date
    Jan 2005
    Location
    Bucharest, Romania
    Posts
    5,403

    Default

    You should consult your JTA TM documentation - AFAIK, Weblogic has a very good implementation that handles this issue (for that you should use the WebLogicJtaTransactionManager).
    Costin Leau
    SpringSource - http://www.SpringSource.com- Spring Training, Consulting, and Support - "From the Source"
    http://twitter.com/costinl
    Please use [ c o d e ] [ / c o d e ] tags

  3. #3
    Join Date
    Nov 2005
    Posts
    12

    Default

    Hi,

    I am using the WebLogicJtaTransactionManager, however I don't think it has anything to do with resuming transactions. I will look at the documentation though. However, I thought that if Method C is set at PROPAGATION_REQUIRED, then it should pick up the suspended transaction and resume it?

    Roshan

  4. #4
    Join Date
    Jan 2005
    Location
    Bucharest, Romania
    Posts
    5,403

    Default

    I think you can find more details on the dev mailing list.
    Costin Leau
    SpringSource - http://www.SpringSource.com- Spring Training, Consulting, and Support - "From the Source"
    http://twitter.com/costinl
    Please use [ c o d e ] [ / c o d e ] tags

  5. #5
    Join Date
    Aug 2004
    Posts
    1,104

    Default

    I don't think it's possible using Spring or EJB transactions. You are basically looking for a PROPAGATION_REQUIRES_PREVIOUS transaction setting.

    What's your use case for this reuirement?

    I think you will have to break your code into finer grained methods like this.

    A REQUIRED
    |
    v
    B SUPPORTS
    |
    |--> B1 NOT_SUPPORTED
    |-> B2 SUPPORTS --------------> C SUPPORTS
    '-> B3 NOT_SUPPORTED
    Last edited by trisberg; Jan 7th, 2006 at 09:33 AM.
    Thomas Risberg
    SpringSource by Pivotal
    http://www.springsource.org

  6. #6
    Join Date
    Nov 2005
    Posts
    12

    Default

    Well, what I am trying to do is work against two databases. For one database, we cannot use transacations, but we can use transacations against the second one. We are trying to stream data from one into the other. Now we have Database1 and Database2. And we are trying to stream data from Dbase1 to Dbase2. So we have a Dbase1DAO that takes an InputStream from DBase1 and streams it into Dbase2. We have that working, however all this happens in one function because we do not want to handle the ResultSet returned from DBase1 outside of its DAO. So from what you said before this is the sort of pseudo-code we need to do:

    ExecutionController:

    Call DBase1DAO.streamData(): //PROPAGATION_REQUIRED
    --inputStream = DBase1DAO.getInputStream() //Suspend Transaction
    --Call DBase1DAO.connectStream(inputStream) //Resume Trasaction
    --Close connection to DBase1 and DBase2

    Now the problem with this code is that the TransactionInterceptor does not change the transactions between function calls inside the same class. Is there some way that I can cause the Interceptor to intercept the call to getInputStream() and attach a PROPAGATION_NOT_SUPPORTED to it?

    Thanks!

  7. #7
    Join Date
    Aug 2004
    Posts
    1,104

    Default

    In that case, you must have two datasources - set it up so that one participates in the transaction and one that does not. So, you should be able to run the whole thing within a transaction, one of the databases are just not participating in the transaction.
    Thomas Risberg
    SpringSource by Pivotal
    http://www.springsource.org

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •