JMS: The difference between Message Acknowledgement and Transacted Session
2012-10-22 12:36
344 查看
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()and
Session.recover()are similar to
Session.commit()and
Session.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()invokes
Message.acknowledge()under the covers and
Session.rollback()invokes
recover().
However, if you're dealing with multiple JMS resources withing the same session (or multiple consumers/producers), the transacted session mechanism 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 mechanisms 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 to
this article.
From: http://myarch.com/message-acknowledgement-or-transacted-session
相关文章推荐
- JMS: The difference between Message Acknowledgement and Transacted Session
- What is the difference between a Session and a Cookie?
- [Error Code]:RequestTimeTooSkewed, [Message]:The difference between the request time and the current
- The difference between SendMessage and PostMessage
- 【JS】The differences between 基本类型 and 引用类型
- The difference between POP3 and IMAP
- What are the differences between SRAM and DRAM?
- Understanding the differences between client/server and peer-to-peer networks
- test the difference between "DEFAULT NULL" and "DEFAULT 0"
- What is the basic difference between NSTimer, NSTask, NSThread and NSRunloop?
- The difference between Asp.Webpart and WSS.Webpart baseclass
- The Differences Between C++ and Java
- the difference between Activity.managedQuery and ContentResolver.query
- The differences between BLOB and TEXT
- the difference between grammar and syntax
- Linux Kernel: What is the major difference between the buffer cache and the page cache?
- what`s the difference between the tools and platform-tools directories
- (ZT)What’s the Difference Between Chromium and Chrome?
- What is the difference between application server and web server?
- numpy : the difference between row and column vector