users@glassfish.java.net

Re: jms bug in glassfish? (for synchronous consumption)

From: Sivakumar Thyagarajan <Sivakumar.Thyagarajan_at_Sun.COM>
Date: Thu, 24 Jan 2008 20:24:10 +0530

Hi

ewernli is correct.

As mentioned in the Java EE tutorial
[http://docs.sun.com/app/docs/doc/819-3669/6n5sg7cj9?a=view#bncgh]
>> You can combine several sends and receives in a single JMS API
>> local transaction. If you do so, you need to be careful about the
>> order of the operations. You will have no problems if the
>> transaction consists of all sends or all receives or if the
>> receives come before the sends. But if you try to use a
>> request/reply mechanism, whereby you send a message and then try
>> to receive a reply to the sent message in the same transaction,
>> the program will hang, because the send cannot take place until
>> the transaction is committed

and at http://docs.sun.com/app/docs/doc/819-3669/6n5sg7cjl?a=view#bncgs

>> In a Java EE application that uses the JMS API, you can use
>> transactions to combine message sends or receives with database
>> updates and other resource manager operations. You can access
>> resources from multiple application components within a single
>> transaction. For example, a servlet can start a transaction,
>> access multiple databases, invoke an enterprise bean that sends a
>> JMS message, invoke another enterprise bean that modifies an EIS
>> system using the Connector architecture, and finally commit the
>> transaction. Your application cannot, however, both send a JMS
>> message and receive a reply to it within the same transaction;
>> the restriction described in Using JMS API Local Transactions
>> still applies.

a message _cannot_ be sent _and_ received within the same transaction
and that is why your testcase behaves as you have described.

HTH
Thanks
--Siva.