This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
I've used the Container Managed Transaction in the JMS sender code (TestJMS.java) which sends message to a JMS Queue. The JMS message receiver is an MDB (TestJMSReceiver.java).
Problem: I want that if an exception is thrown inside the sender code TestJMS-->sendMessageTest1(String s) then the transaction should be rolled back which means:
(i) The Entity JmsTestTable should not be saved (look inside sendMessageTest1() method of TestJMS.java)
(ii) The JMS Message sent should be destroyed and it should not be received by JMS Receiver-MDB (TestJMSReceiver).
The (i) option happens but not the (ii) one. This means that message is still being sent to Queue and it is still received by the MDB which is clear from the logs generated by MDB.
The code listing follows: