ASG
IBM
Zystems
Cressida
Icon
Netflexity
 
  MQSeries.net
Search  Search       Tech Exchange      Education      Certifications      Library      Info Center      SupportPacs      LinkedIn  Search  Search                                                                   FAQ  FAQ   Usergroups  Usergroups
 
Register  ::  Log in Log in to check your private messages
 
RSS Feed - WebSphere MQ Support RSS Feed - Message Broker Support

MQSeries.net Forum Index » IBM MQ Java / JMS » Transactions, JMS sessions and Session EJBs

Post new topic  Reply to topic
 Transactions, JMS sessions and Session EJBs « View previous topic :: View next topic » 
Author Message
JustinM
PostPosted: Fri Jun 28, 2002 3:20 am    Post subject: Transactions, JMS sessions and Session EJBs Reply with quote

Novice

Joined: 10 Apr 2002
Posts: 13

Hi

I have a particularly pertinent question that I have been trawling the web to answer with no success. The scenario is as follows:

I have a Session EJB (container managed transactions) that puts several messages on a queue. For each message, a database entry is created. If the 'unit of work' fails for any reason (e.g. database failure, JMS provider failure) during the process, the database should be rolled back and the messages should not be put on the queue.

Two session beans are involved (both with container managed transactions).

The Correspondence Session bean puts a List of messages on a queue one by one using a single session.:

...
queueConnection.start();
session = queueConnection.createQueueSession(true, 0);
QueueSender sender = session.createSender(queue);
for (int i=0, j=requestList.size(); i <j; i++) {
CorrespondenceRequest request = (CorrespondenceRequest)requestList.get(i);

// get a tracking number
.....
// put the message on the queue ObjectMessage requestMessage = session.createObjectMessage();
requestMessage.setObject(request);
sender.send(requestMessage);
}
// commit the jms unit of work
session.commit();

The UpdateAccount Session Bean creates a database entry for every request sent (using the tracking number as a foreign key)

The scenario I want to be able to avoid is this:
1) The Correspondence Session bean puts the messages on the queue
2) The Account Session bean creates entries in the database but fails for some reason. The transaction is rolled back
3) The messages still persist on the queue

i.e.The messages should not be committed to the JMS Queue until the session bean method commits.

I understand that distributed transactions may be a solution to a problem of this nature.
What I would like to know is: surely the SessionBean should automatically enlist the JMS session's transactional context in its context and thus rollback JMS session's transaction if the session beans transaction fails. In other words I should not have to call session.commit() on the JMS Session.

Am I missing the mark here or do you have any resources that you can share with me to help solve this problem?

(We are writing to the EJB 1.1 spec, using Websphere 4.0.2 as a container and MQSeries as the messaging resource)

Thanks

JustinM
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » IBM MQ Java / JMS » Transactions, JMS sessions and Session EJBs
Jump to:  



You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Protected by Anti-Spam ACP
 
 


Theme by Dustin Baccetti
Powered by phpBB © 2001, 2002 phpBB Group

Copyright © MQSeries.net. All rights reserved.