0 Replies Latest reply on Jan 1, 2002 11:40 AM by Corby Page

    MDB's and non-transacted queues

    Corby Page Newbie

      I have an MDB that receives messages from a queue, Q1, for messages. It attempts to process the message, and this processing involves numerous database writes. If something goes wrong with the processing, then I wish to rollback my database updates, and copy the message into a second queue, Q2. I never want to rollback operations on Q1 or Q2.

      So I declare my database to be a managed resource for my MDB, but I do not declare Q1 or Q2 to be managed resources. And I use a non-XA connection factory to retrieve my queue connections.

      When my MDB uses bean-managed transactions, it behaves exactly as I expect. That is, committing or rolling back the transaction will determine whether or not writes occur to the database, but it has no effect on whether a message is pulled out of Q1 or sent into Q2.

      But when my MDB uses container-managed transactions, the behavior is inconsistent. Committing the transaction causes it to behave as expected. But if I call setRollbackOnly() on the MessageDrivenContext, it rolls back the datasource AND Q1, but not Q2. (Of course, this causes the message to infinitely redeliver, process with error, and successfully forward on to Q2).

      I think this is a bug, and that the bean should not rollback Q1 when it is CMT, just like it doesn't when it is BMT. But before I report it as such, I wanted to get feedback to see if I am missing anything.

      Happy new year!
      Corby