Announcement Announcement Module
Collapse
No announcement yet.
XA TransactionManager provides any hook before commit? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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
    Could somebody please share knowledge on this?

    Thanks,
    Shashi

    Comment


    • #3
      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.

      Comment


      • #4
        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

        Comment


        • #5
          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.

          Comment

          Working...
          X