In JMS, a transaction applies to the operations performed by a JMS client. A JMS 
client is an Java application that uses the JMS API to send or
receive messages.

When you send a message with JMS, that operation can be part of a transaction which 
ensures that the message will not be delivered if the transaction
fails. Receiving a message can also be part of a transaction so that if the receive 
operation fails, the message may be redelivered to the client by
the MOM at a later time.

While the sends and receives of a single client can be included in the same 
transactions of the same JMS client, transactions do not span clients. So,
for example, if client A sends a message to client B.  The transaction doesn't extend 
from client A to client B. This is very different from EJB where
a transaction can be propagated from the client to the server.  This type of 
transaction propagation between nodes is only practical with synchronous
RPC style distributed systems. EJB is synchronous RPC, while JMS is an asynchronous 
messaging technology.

JMS transactions can be included in 2PC if the vendor supports XA transaction. This 
makes it possible to include JMS operations (sending or receiving)
in the same transaction as JDBC data access or invoking other beans.  If for example, 
an enterprise bean updates some data using JDBC and then sends a
JMS message, both JDBC update and the JMS send operation can be part of the same 
transaction.  If the JMS provider (message middleware) fails to
deliver the JMS message, the entire transaction will rollback so that the database 
updates are also rolled back.  That's a very powerful concept.

Most JMS vendors don't support 2PC yet, but that will change very quickly.  Some EJB 
vendors, Weblogic is one, can include JMS messages and JDBC
accesss in the same local transactions provided they use the same database. (JMS 
vendors often use a RDBMS to persist messages while messages are in
transit from a sender to a receiver).

The JMS question you asked is very basic. Its probably something you could have 
figured out yourself with a little bit or research. You can learn a
lot more about JMS by reading one of the JMS books that are available today -- I 
co-authored the O'Reilly one. Also there is a JMS tutorial on Sun's
JDC which I have heard is very good overview.

Richard
--
Richard Monson-Haefel
Author of Enterprise JavaBeans, 2nd Edition  (O'Reilly 2000)
Co-Author of Java Message Service (O'Reilly 2000)
http://www.jMiddleware.com


MohammedAbubucker Alathick wrote:

> hi friends
>
> when i was learning JMS i came across this concept of Transactions.I don't 
>understand what is meant by transaction in relevance to JMS.Pls explain
>
> _____________________________________________________
> Chat with your friends as soon as they come online. Get Rediff Bol at
> http://bol.rediff.com
>
> ===========================================================================
> To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
> of the message "signoff EJB-INTEREST".  For general help, send email to
> [EMAIL PROTECTED] and include in the body of the message "help".

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff EJB-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

Reply via email to