JMS: The difference between message acknowledgement and transacted session

Source: Internet
Author: User
Message acknowledgement or transacted session? Posted on 05/30/2011,
No Comments (ADD)

JMS is one of the oldest Java EE specifications (JMS 1.0 specification is dated 11/1999), however, questions about
The difference between message acknowledgement and transacted session still come up. The difference is especially subtle when programmatic client acknowledgement (Session.CLIENT_ACKNOWLEDGE) Is used since
Message.acknowledge()AndSession.recover()Are similar
Session.commit()AndSession.rollback(). So how are these
APIS different?

The bottom line is that there is no difference if you deal only with a single resource (queue or topic) within a session. if all you do is consuming messages from a single queue, it does not matter whether you use acknowledgements or transacted sessions
(Although in my opinion it is more intuitive to use session. Commit/rollback ).
Session.commit()
InvokesMessage.acknowledge()Under the covers and
Session.rollback()Invokesrecover().

However, if you're dealing with multiple JMS resources withing the same session (or multiple consumers/producers), The transacted session mechanic is what you want to use. for example, you may consume messages from one queue and
Then put messages on a different queue using the same JMS
Session. the transacted session will treat all consumed and produced messages as part of a single transaction and will commit or rollback all messages at once. message acknowledgement on a non-transacted session will "commit" consumed messages independently
Of the produced ones.

Transacted sessions are limited to JMS resources; container-managed transactions and
JTA is required to managed JMS
And non-JMS resources (e.g., getting a message from a queue and updating a database ).

As a summary, the different mechanic ISMs discussed here differ in terms of the types of resources managed as part of transactions:

  • Message Acknowledgement: messages consumed from a single destination.
  • Transacted session: Multiple JMS resources within the same
    JMS session.
  • Container-managed transactions: Multiple JMS and non-JMS resources.

For a more in-depth discussion of different transaction mechanisms, refer
This article.

 

From:

Http://myarch.com/message-acknowledgement-or-transacted-session

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.