• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Confused by Ets's 2 questions

 
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
When a CMT message-driven bean with REQUIRED attribute rolls back a transaction but no exception thrown, will the message be redelivered?
The answers of the 2 questions seem to be contradictory.

In Enthuware Test 4 Question no.49:
"
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.

11. public void myBeanMethod()
12. {
...
21. UserTransaction ut = ejbContext.getUserTransaction();
22. ut.begin();
23. queueSender.send(message); //sends a message to a queue Q1.
24. stmt.executeUpdate(query1);
25. ut.rollback();
...
30. }

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?
"

The correct answer is "Neither the message is sent nor any database changes get committed."

The explanation says
"
In this case, the sending of the message is a part of MyBean's transaction. Therefore, if it rollsback the transaction, the message will not be sent.
The message will not be redelivered because it was never sent!
"

HOWEVER, in Test 4 Question No.51, the correct answer is "The transaction started by the MDB is rolledback and JMS Message redelivery semantics will apply."
 
So I left, I came home, and I ate some pie. And then I read this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic