Problem:
I am writing a method in a session bean with the TX_REQUIRED property set. At the end of the method i would like to post a message to a jms server. If afterwards the transaction fails, than the message will still be delivered. This i understand but can not accept.
My Solution:
Certainly i could put
the code of sending the message in another method which will be called afterwards by the client or
i could try to commit the transaction explicitly before sending the message ( even though i do not know how to).
My Question:
Both of the above is not satisfying. Rather i would like some "transaction secure" message queue meanig the message will only be posted if the transaction has taken place. Does such a thing exist? Thank you in advance for the concern.
-
How to send a transaction secure asynchronous message? (3 messages)
- Posted by: g s
- Posted on: February 27 2002 07:14 EST
Threaded Messages (3)
- How to send a transaction secure asynchronous message? by Gal Binyamini on February 27 2002 19:33 EST
- How to send a transaction secure asynchronous message? by Andrew Debkowski on April 04 2002 15:32 EST
- How to send a transaction secure asynchronous message? by Neeraj Nargund on March 04 2002 14:36 EST
-
How to send a transaction secure asynchronous message?[ Go to top ]
- Posted by: Gal Binyamini
- Posted on: February 27 2002 19:33 EST
- in response to g s
I'm not sure I understand your question, but let us look at this scenario:
void method() {
do stuff
send JMS message
}
If the transaction method() ran in fails at any point, the JMS message will not be delivered. When JMS connections are transacted (which is the case in EJB), all the messages you send in a transaction are kept in a local buffer, and are not delivered to their destination. Similarly all messages you recieve are not acknowledged. When the transaction commits all the outgoing buffer is flushed and the incoming messages are acknowledged. If the transaction rolls back, nothing gets sent and all the messages you recieved are scheduled for redelivery.
Does this solve your problem? Or am I not getting your question?
Gal
-
How to send a transaction secure asynchronous message?[ Go to top ]
- Posted by: Andrew Debkowski
- Posted on: April 04 2002 15:32 EST
- in response to Gal Binyamini
Gal
Is this also true in EJB 1.1 (for publishing messages of course)...??
We will be using WAS 4.0 and it doesn't support EJB 2.0 yet
from what I understand. We would still gain advantage from using JMS to publish from our EJB's. The transactional support of buffering the messages until commit would solve some problems...
Thanks
AJD -
How to send a transaction secure asynchronous message?[ Go to top ]
- Posted by: Neeraj Nargund
- Posted on: March 04 2002 14:36 EST
- in response to g s
hmm..
if i get your ? right...
methodA(){
some transaction..
}
after transaction send message..
if this is so
boolean methodA(){
if(logic)
return true;
else return false
}
if(methodA()){
send message()
}