posted 19 years ago
Here's a sample question from a JDiscuss mock exam:
Question No: 28 (Question ID: 1940) Exceptions : Real Brainer
Consider the following code occuring in a MyBean code. It updates the database and sends a message to a queue named Q1. The message driven bean (not same as MyBean) associated with the queue requires a transaction and updates the database upon receiving a message.
Assuming that all the variables are properly defined and used, what will happen if the MDB associated with the queue Q1 rolls back the transaction but does not throw any exception?
Select 1 correct option.
Changes made by the bean code at line 24 will be committed.Line 25 will throw an ExceptionThe message will be sent to the queue.The message will be sent to the queue but the changes made to the database by the MDB will not be committed.The container will resend the message to the queue.Neither the message is sent nor any database changes get committed.
The mock exam marks the last option as correct, while I assumed it was the 1st. Unfortunately, no other explanations are given. So please clear this up for me...it's probably somtehing with the message send() and the MDB rolling back its tx that causes the client transaction to roll back, but I'm not clear what and why - my guess is that the client code and the MDB's onMessage() run in separate transactions since the MDB requires a TX and the client's TX cannot be propagated to it [the client never "sees" the bean].
Thanks a bunch!
[ September 09, 2005: Message edited by: Mihai Alexe ]
SCJP for Java 1.4<br />SCBCD for J2EE 1.3