Added: incubator/activemq/site/How+do+transactions+work URL: http://svn.apache.org/viewcvs/incubator/activemq/site/How%2Bdo%2Btransactions%2Bwork?rev=374430&view=auto ============================================================================== --- incubator/activemq/site/How+do+transactions+work (added) +++ incubator/activemq/site/How+do+transactions+work Thu Feb 2 08:31:10 2006 @@ -0,0 +1,243 @@ + + + + + + + + ActiveMQ - How do transactions work + + + + + + + + + + + + + + + +
+ + + + + + +
+

Overview

+ +

Community

+ +

Using ActiveMQ

+ +

Features

+ +

Connectivitiy

+ +

Utilities

+ +

External Tools

+ +

Related Projects

+ +

Support

+ +

Developers

+ +

Tools we use

+ +

Feeds

+ + + + + + + + + +
+
+
+ Site +
+ + + News +
+
+ +
+ + + + + +
+ How do transactions work + + +
+
+ + +
+
+

There are 2 kinds of transaction support in ActiveMQ.

+
    +
  • JMS transactions - the commit() / rollback() methods on a Session (which is like doing commit() / rollback() on a JDBC connection)
  • +
  • XA Transactions - where the XASession acts as an XAResource by commmunicating with the Message Broker, rather like a JDBC Connection takes place in an XA transaction by communicating with the database.
  • +
+

They are both implemented fairly similarly. When operations are carried out on a transacted (or XA transacted) session, a transaction command is sent to the broker, with a unique transaction ID which is then followed by all the usual commands (send message, acknowledge message etc).

+

Then when a commit() or rollback() is called on the Session, this command is sent to the broker for it to commit or rollback the transaction.

+

Now the operations carried out on a transacted session inside a transaction, like a send message or acknowledge message, do not really perform a real send or acknowledge until the commit occurs. So the Broker explicitly handles these cases separately - essentially buffering up the commands until the commit occurs when the messages are really sent or acknowledged.

+

If you wanna see the code, take a look at the methods

+ +

Which differ from the normal operations

+ +

The only real difference with XA transactions is that at the PREPARE stage we MUST write every command we have received (the send message or acknowledge message commands) to a persistent store so that we can recover properly.

+

For this we write the commands to the PreparedTransactionStore

+
+
+ +   +