• 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
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

EJB with CMT sending JMS message

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,

I have a problem with container managed transactions in a stateless session bean sending a jms message.
It seems i can't include my JMS session in the transaction.

Here's the code:

Problem is that no message ends up on the queue when the enqueueOrder method completes, and i would expect the container to commit the transaction. Method completes ok without throwing any exceptions.

However if I change to: the message is placed on the queue when the send(message) call completes. But that means the jms session is not part of the EJB transaction.

My app-server is JBoss5.1, and there are no consumers on the queue.

I'm probably missing something blindingly obvious, but i just can't spot it. Any help appreciated.

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

you should commit the session when it is transacional.


 
Nicki Carstensen
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Michael,

Thanks for your tip, you are correct, if i call session.commit(); the message ends up on the queue.

But that confuses me .
I thought that when using
in a JEE container, the application server would create a resource adapter that wraps the real jms connection, enabling container managed transactions.

Please enlighten me if I'm wrong.
 
Nicki Carstensen
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Found the solution!

JBoss provides resource adapter for JMS at java:/JmsXA, not at java:/ConnectionFactory in JNDI.

Here is the changed code:

Rest is still the same:

Messages are now placed on the queue when method completes and container commits transaction.
 
The world's cheapest jedi mind trick: "Aw c'mon, why not read this tiny ad?"
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic