Weblog

All | Personal | Sun
« Add other JMS subscr... | Main | Web service client... »
20051129 Tuesday November 29, 2005

Transactions and JMS I started to talk about JMS thence I might write a few sentences about transactions. Very often use case is that you deliver message and then this message is stored in database. How we can solve this. Should we use JTA for this?
I hope that reader knows that you mustn't use global transaction for consumer and producers. Why? Because, having all producers and all consumers participate in one global transaction would defeat the purpose of using a loosely coupled asynchronous messaging environment. JMS transactions follow the convention os separating the send operations from the receive operations. Which ways do we have for transactions with JMS?

Posted by pblaha ( Nov 29 2005, 07:55:00 PM CET ) Permalink Comments [2]

Trackback URL: http://blogs.sun.com/pblaha/entry/transactions_and_jms
Comments:

Petr,

Thank you for posting this blog. I am having a similar 'database transaction rolls back and then message gets redelivered for ever' problem.

Can I just clarify:

  1. You are saying that JMS will redeliver the message if the database rolls back even if you catch the Exception and stop it bubbling out of onMessage (how does it know the Exception happened in this case?)
  2. If you throw an EJBException from onMessage, JMS will never try to resend the message? Is this a side-effect or is this in the spec?
Thanks,

Richard.

Posted by Richard Kennard on March 28, 2006 at 05:09 AM CEST #

I have a question on transactions involving JMS message sends, and invoking method calls. Consider the following case:

BEGIN TXN

  • 1. ejb1.method1();
  • 2. ejb1.method2();
  • 3. sendJMSMessage();
  • 4. ejb1.method3();
  • 5. ejb1.method4();

  • END TXN

    My questions are: 1. What happens to the JMS messages already sent if the transaction needs to be rolled back at step 5? 2. If the JMS Messages are not sent until the transaction commits, isn't that similar to putting step 3 after all the ejb calls? Thanks, Nitin

    Posted by Nitin on April 27, 2006 at 01:53 PM CEST #

    Post a Comment:

    Name:
    E-Mail:
    URL:

    Your Comment:

    HTML Syntax: NOT allowed

    Calendar

    RSS Feeds

    Search

    Links

    Navigation

    Referers

    Older blog entries