I think your question is incomplete, BUT IM NOT 100 % SURE. you should specify Runtime Ex is a App Ex or Sys Ex, and Tr argument of MDB
Usually the runtime exception will lead to a rollback. What then happens to your message depends on the transaction type: In CMT the message will be put back into the queue and will be processed again (probably throwing the same runtime exception again, and so on); in BMT your message is deleted from the queue and can't be recovered.
What happens to the original message? Will it be put back to the Queue and if so how ?
... in BMT your message is deleted from the queue and can't be recovered. ...
Core spec, section 5.4.17 says:
If a message-driven bean uses bean-managed transaction demarcation and throws a RuntimeException, the container should not acknowledge the message
so I think that in this case the message will not be deleted from queue.
By "usually" I meant those runtime exceptions that are not application exceptions. But of course you're right: It's always better to use the terms "application exception" and "system exception".
I can't agree on that.. All Runtime Exceptions are not System Exceptions,
The core spec, 5.4.12 says:
so I think that in this case the message will not be deleted from queue
Note: Queuing systems work in a transactional way. So if in BMT the physical removal of the message from the queue would depend on the result of the user transaction you would need an outer transaction handling the queue and spanning the inner user transaction. But there is no requirement for nested transactions in ejb.
When a message-driven bean using bean-managed transaction demarcation uses the javax.transaction.UserTransaction interface to demarcate transactions, the message receipt that causes the bean to be invoked is not part of the transaction. If the message receipt is to be part of the transaction, container-managed demarcation with the REQUIRED transaction attribute must be used.
By the way, using a simple message consumer you can easily check that in the questionable BMT scenario there is no message in the queue after a system exception occured in the MDB.
SCJP 5.0 (98%)
[ November 02, 2008: Message edited by: Ralph Jaus ]