File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Java in General and the fly likes Query regarding Database commit and Queue Commit Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Query regarding Database commit and Queue Commit" Watch "Query regarding Database commit and Queue Commit" New topic

Query regarding Database commit and Queue Commit

Sumit Ranjan

Joined: Dec 20, 2005
Posts: 24

Let me first give a brief introduction of the business scenario -

I am using JMS Queues and I have a Java application which listens on this queue constantly. Wheneever, there is a message on this queue, it is picked by this Java application and a stored procedure is called internally and the data from the message is stored in the database tables.In an ideal scenario,the message would be succesfully parsed and the data would be succesfully commited into the database and then the Queue would be committed.

The problem with this approach
Imagine now, that due to some reasons, the database commit was succesful but the Queue commit fails. In this scenario, the same message would be picked by the java application listening on the Queue and all the cycle repeats again which is not desirable at all.

So, I am looking for a solution wherein either both the database and the Queue commit or both Rollback.

Thanks in advance !!!

Jeremy Botha
Ranch Hand

Joined: Feb 16, 2005
Posts: 125
Why not,as your first step when receiving a message, check whether a duplicate exists in the database; if so, disregard the incoming message.

You should be able to do a simple select based on the criteria of the message; I assume you're using some form of compound key based on message properties.

This is probably simpler than trying to get a transactional rollback system working.

Failing that, I believe there are several distributed transactional systems for JMS. What JMS Server are you using?


McFinnigan? Never heard of him. Nobody here but us chickens...<br /> <br />SCJP for Java 1.4<br />SCJD for Java 5.0
I agree. Here's the link:
subject: Query regarding Database commit and Queue Commit
It's not a secret anymore!