|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
 |
|
deleting a message after browsing |
« View previous topic :: View next topic » |
Author |
Message
|
erg |
Posted: Sun Mar 18, 2007 7:09 pm Post subject: deleting a message after browsing |
|
|
Newbie
Joined: 08 Mar 2007 Posts: 2
|
Hi,
To minimise the possibility of losing a message (for example, if my application crashes after getting a message but before processing it), I am trying to implement a mechanism to read the message at the head of the queue, then when I'm finished processing it, delete it from the queue.
I would like a mechanism that works for both local queues and remote queues.
I currently call MQOPEN as follows:
openOptions = MQOO_INPUT_AS_Q_DEF
+ MQOO_FAIL_IF_QUIESCING
+ MQOO_BROWSE;
MQOPEN(connectionHandle, &od, openOptions, &objectHandle, &openCode, &reason);
I then call MQGET with the following options:
gmo.Options |= MQGMO_BROWSE_FIRST;
gmo.Options |= MQGMO_LOCK;
MQGET(connectionHandle, objectHandle, &md, &gmo, peekMessageLength, *hOutputData, &messlen, &completionCode, &reason);
When I'm done, i call MQGET with a NULL data pointer (because I don't want the data again) and the following options:
gmo.Options |= MQGMO_UNLOCK;
gmo.Options |= MQGMO_DELETE_MSG;
gmo.Options |= MQGMO_MSG_UNDER_CURSOR;
MQGET(*pConnectionHandle, *pObjectHandle, &md, &gmo, peekMessageLength, NULL, &messlen, &completionCode, &reason);
This doesn't appear to delete the message from the queue. Anyone able to help?
Many thanks,
Erg. |
|
Back to top |
|
 |
Michael Dag |
Posted: Sun Mar 18, 2007 11:17 pm Post subject: Re: deleting a message after browsing |
|
|
 Jedi Knight
Joined: 13 Jun 2002 Posts: 2607 Location: The Netherlands (Amsterdam)
|
erg wrote: |
Hi,
To minimise the possibility of losing a message (for example, if my application crashes after getting a message but before processing it), I am trying to implement a mechanism to read the message at the head of the queue, then when I'm finished processing it, delete it from the queue.
|
reinventing COMMIT? look at
Code: |
MQGET with SYNCPOINT
do processing
MQCOMMIT |
_________________ Michael
MQSystems Facebook page |
|
Back to top |
|
 |
Vitor |
Posted: Mon Mar 19, 2007 1:35 am Post subject: Re: deleting a message after browsing |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
erg wrote: |
I would like a mechanism that works for both local queues and remote queues. |
Any mechanism to browse and remove messages from remote queues is doomed to fail, for reasons which should be obvious.
There's no equivalent to browse for PUT. Do as Michael Dag suggests and use syncpoint; you've paid (or your company's paid) a lot of money for the MQ license and it's only fair you get the benefit of all the facilities provided.
To answer your specific question, your code won't do what you intend as written. Check out the Application Programmer's Reference and re-read what the get options do.
But you don't want to do this for only the reason you give. Browse is highly inefficient and expensive as an API, this will kill your performance. You need a serious requirement before attempting this. _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
jefflowrey |
Posted: Mon Mar 19, 2007 11:39 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
I'll third "Use Syncpoint".
Also, you can't GET from remote queues. _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
moe |
Posted: Tue Apr 10, 2007 12:07 am Post subject: |
|
|
Apprentice
Joined: 05 Sep 2006 Posts: 33 Location: Sydney, Australia
|
I vote for syncpoint, counter-productive re-inventing what mq is specialised at doing. Good luck  |
|
Back to top |
|
 |
|
|
 |
|
Page 1 of 1 |
|
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
|
|
|
|