Author |
Message
|
koumides |
Posted: Wed Aug 11, 2010 11:04 am Post subject: Reading Message without deleting |
|
|
Newbie
Joined: 11 Aug 2010 Posts: 2
|
All,
I have a server application which listens to messages from MQ Queue.
At the moment I am reading messages, processing them and writing the results in the database. The problem I have is I don't want to delete them from the queue as soon as I read read them but instead I prefer to delete the message as soon as confirm it has been succesfully written in the database.
Any ideas?
I am using .NET API (C#) running on Windows 2003 server.
Thanks,
MK |
|
Back to top |
|
 |
mqjeff |
Posted: Wed Aug 11, 2010 11:25 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
|
Back to top |
|
 |
koumides |
Posted: Wed Aug 11, 2010 1:34 pm Post subject: Not sure |
|
|
Newbie
Joined: 11 Aug 2010 Posts: 2
|
I am not sure I have understood the previous reply.
Can someone please explain it a bit more? |
|
Back to top |
|
 |
mvic |
Posted: Wed Aug 11, 2010 2:16 pm Post subject: Re: Reading Message without deleting |
|
|
 Jedi
Joined: 09 Mar 2004 Posts: 2080
|
koumides wrote: |
I don't want to delete them from the queue as soon as I read read them but instead I prefer to delete the message as soon as confirm it has been succesfully written in the database. |
Why are you checking the database - is it because the messages are important and must not be lost?
You should instead be using units of work. Preferably global units of work managed by Transaction Manager software that knows how to coordinate updates to MQ and the database under a single unit of work.
In answer to your original question, the thing to search for is browse. If you "browse" a message it is not removed from the queue. |
|
Back to top |
|
 |
mqjeff |
Posted: Wed Aug 11, 2010 2:50 pm Post subject: Re: Not sure |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
koumides wrote: |
I am not sure I have understood the previous reply.
Can someone please explain it a bit more? |
I have pointed you to the section on creating and using units of work within a Windows environment.
This will tell you how to configure your system so that you can ensure that if the database transaction fails, the mq transaction will be rolled back and vice versa.
You want to solve this problem using units of work, particularly global units of work. You do not want to solve this problem using browse, because you will have to write a large amount of code to ensure that you only destructively read the message after you have ensured the success of the database transaction.
This code would be duplicating all of the code that has helpfully been written and extensively tested for you that comes with MQ and windows to coordinate global units of work.
Read the section of the documentation I have pointed you at. Read it's subsections. Then find the section in the InfoCenter on using .NET code and find where it talks about using Commit() and Rollback() and other unit of work considerations. |
|
Back to top |
|
 |
|