1 Reply Latest reply on Sep 9, 2005 1:17 AM by Elias Ross

    does jboss mq support nested transactions or should i use so

    Tom Baeyens Master

      I want to evaluate if this is proper usage of JMS. Hints or suggestions are appreciated.

      Here's what i want to do: A message consumption and some database updates should be combined in a global transaction.

      (I have a queue-destination listener that receives and executes commands. The commands perform updates on a database connection)

      Now the question is: how to deal with commands that throw an exception. I should roll back the database updates. But i should mark the message somehow that it couldn't be executed (e.g. by moving the message to an error-queue or something...)

      One solution i see is to use 2 separate local transactions (1 for db and 1 for message consumption) instead of 1 global transaction. But of course, that could lead to inconsistent state in case of a server crash.

      Another solution might be using nested transactions. But does JBoss and/or JTA support that ?

      Any recommendation is appreciated.

      regards, tom.

        • 1. Re: does jboss mq support nested transactions or should i us
          Elias Ross Master


          If you use an MDB, if the message fails it should go to the DLQ, you can configure this to happen after one try. (This isn't transactionally safe, from what I've heard.)

          Alternatively, you could check the 'redelivered' flag on the message in an MDB. So:

          1. MDB receives message
          2. Do database processing, fails, roll back
          3. Message redelivered ... instead of retrying the DB transaction, add the message to a different queue, consume the current message.