You can rely on JTA to transparently manage both your JMS and EJB transactions only if both vendors (or one if both are the same) support XA transactions, and you have XA turned on.  Note that even if both JMS and EJB are in the same container, they may use different DataSource and will still require XA.

If your vendor(s) do not support XA, then you will have to manually session.commit()/rollback().

Gene

  Benjamin BONNET <[EMAIL PROTECTED]> wrote:

Hi,

The container should do it all for you since your method is transactionnal (see EJB specs 2.1 �17 for details)
 

Simon Zeng wrote:

You can make your JMS Message transacted. (ie. the first parameter in
creatTopicSession/creatTopicSession should be TRUE). Call session.commit()
if your EJB transaction complete; otherwise, call session.rollback().
JMSServer won't send the message to consumer until it receives a commit
Command. Hope this works for you.
 

Simon, in a transactionnal business method, you should not commit nor rollback manually your JMS session (see 17.3.4). It is the
responsibility of the container to do it (the container has to deal with all the transactionnal resources involved in the transaction).
If you really want to force a rollback on the transaction, you have to use the UserTransaction interface.

Benjamin


Simon Zeng

WaterCove Networks
 

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
Sent: Friday, July 19, 2002 10:47 AM
To: [EMAIL PROTECTED]
Subject: Sending JMS msg from within an EJB transaction

Hi,

one question on JMS: I want to send a JMS message from a business method
of a session EJB. This method runs with a transaction context. The
method also invokes several other calls on entity beans that can
possibly fail and cause a transaction rollback.

Now, the question: I want the JMS message to enlist into the same
transaction - that means, if it is rolled back, the message should *NOT*
be sent. How should I code that?

Regards...
Matthias Bohlen
http://www.mbohlen.de

===========================================================================
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".



Do You Yahoo!?
Yahoo! Health - Feel better, live better

Reply via email to