Results 1 to 5 of 5

Thread: XA TransactionManager provides any hook before commit?

  1. #1
    Join Date
    Jul 2006
    Posts
    126

    Default XA TransactionManager provides any hook before commit?

    Hi,

    We have an application where there would be multiple modules each associated with a different schema.

    Multiple modules may be participating in a transaction for data modification. Hence we require the transaction manager to be XA enabled.

    There is an audit service which tracks the changes done in the model within the transaction and persists the audit data in one of the database schema.
    I would require a hook to call the audit service before the transaction is committed on all the databases participating in the transaction.

    Could somebody please let me know how this can be achieved in a clean manner? Currently I am thinking of extending the JtaTransactionManager provided by spring and call the audit service before calling the super.doCommit. Would this be right approach?

    Would appreciate any pointers for this.
    Thanks,
    Shashi

  2. #2
    Join Date
    Jul 2006
    Posts
    126

    Default

    Could somebody please share knowledge on this?

    Thanks,
    Shashi

  3. #3
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,625

    Default

    Quote Originally Posted by shashi
    I would require a hook to call the audit service before the transaction is committed on all the databases participating in the transaction.
    Why? Why not simply use some AOP for that. 1 thing you have to wonder is does the audit data need to be written in the same or in a separate transaction, it depends on your requirement.
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

  4. #4
    Join Date
    Jul 2006
    Posts
    126

    Default

    Hi Marten,

    Thanks for your reply.

    I am already using an aspect for capturing the data changes. However the audit data captured during the data manipulation done by user has to be persisted only during the data change commit to the persistence store.

    However the audit data needs to be stored to a separate datastore and the actual data would be persisted in a different store. Also the transaction may involve changes in the data stored across multiple datasources. That would require XA. Hence I was wondering if I could call saving the audit data in a hook called during the commit called by the XA transaction manager.

    Regards,
    Shashi

  5. #5
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,625

    Default

    You could try and register your class with the TransactionSynchronizationManager (you could use AOP for that) and implement the required interface and well implement what you need.
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

Posting Permissions

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