0 Replies Latest reply on Oct 5, 2013 4:27 AM by Philippe Marschall

    EJBs and XA transactions (JDBC & JMS) design question

    Philippe Marschall Expert

      We have what I believe is a fairly common XA use case:

      1. Read a message from an in-queue
      2. write some data to a database
      3. write a response message to an out-queue (which is different from the in-queue)

      However we also need a way to handle internal errors and poison messages. The control flow we have in mind is something like this:


      1. read the message from the in-queue
      2. write to the database
        • if there's an exception roll back the database transaction
        • if there's no exception run commit phase1 on the database
      3. if everything went fine (no rollback and commit phase1 ok) write a success message to the out-queue
      4. if either commit phase1 on the database failed or there was an exception and the database transaction was rolled back write a failure message to the out-queue
      5. commit the in-queue, out-queue and database (unless rolled by because of an exception)


      Is this a good approach, should we do it differently? How can we do this with EJBs?