|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
 |
|
Not delete message |
« View previous topic :: View next topic » |
Author |
Message
|
vishu_100 |
Posted: Tue Oct 04, 2011 12:25 pm Post subject: |
|
|
Newbie
Joined: 04 Oct 2011 Posts: 2
|
Hi
below code is get the message from queue after comparing the correl id and get deleted from queue
I dont want to delete it from queue , so can anyone help fo this.
int openOptions = MQC.MQOO_INPUT_AS_Q_DEF |
MQC.MQOO_OUTPUT | MQC.MQOO_BROWSE | MQC.MQOO_INQUIRE ;
MQQueue queue = qMgr.accessQueue(queueName,openOptions,null,null,null);
MQMessage hello_world1 = new MQMessage();
hello_world1.correlationId = correlationId;
MQGetMessageOptions pmo1 = new MQGetMessageOptions();
pmo1.waitInterval =15000;
pmo1.options=MQC.MQOO_INQUIRE;
pmo1.options=MQC.MQOO_BROWSE;
pmo1.options=MQC.MQMO_MATCH_CORREL_ID; queue.get(hello_world1,pmo1);
Please help me for this , Actually the requirment is browsing previous from queue , so i did this. |
|
Back to top |
|
 |
Vitor |
Posted: Tue Oct 04, 2011 12:33 pm Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
vishu_100 wrote: |
hello_world1.correlationId = correlationId; |
I do hope correlationId isn't a string / character variable.
vishu_100 wrote: |
pmo1.options=MQC.MQOO_INQUIRE; |
Why are you specifying inquire?
And
vishu_100 wrote: |
pmo1.options=MQC.MQOO_BROWSE; |
Both inquire and browse are being set with the wrong constants. Those you correctly use in the open options (hence MQOO; they're not the ones you use for Get Message Options.
vishu_100 wrote: |
Actually the requirment is browsing previous from queue , so i did this. |
Two points:
- WMQ does not support browsing the previous message
- Interpreting a message based on the next or previous message is called "affinity" and is a bad design construct.
Alright, three points. Browsing a queue is hideously inefficent and will kill the performance of your application. It should only be done when you really have no option. _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
vishu_100 |
Posted: Tue Oct 04, 2011 12:54 pm Post subject: |
|
|
Newbie
Joined: 04 Oct 2011 Posts: 2
|
Hi Dear ,
Thanks for helping me
Now the code is :
private static void previousMessage(MQQueue queue,byte b_msg [],byte correlationId [] )throws Exception
{
MQMessage hello_world1 = new MQMessage();
hello_world1.correlationId = correlationId;
MQGetMessageOptions pmo1 = new MQGetMessageOptions();
pmo1.waitInterval =15000;
pmo1.options=MQC.MQMO_MATCH_CORREL_ID;
queue.get(hello_world1,pmo1);
System.out.println("*"+hello_world1.readStringOfCharLength(hello_world1.getTotalMessageLength()));
}
but the message was deleted from queue after this code run , it will print perfect message but after that it will deleted .
Actually If MQ dosn't support previous option
then I have last option that I will store the position and message in server cache, but it is not a perfect code ,
So Is there any option from I will pick the message either by msgId or correlID without removing the cache.
Even I am using the BrowseCursor option but GET() will return the message and cursor will be on the next message , and if I using Browse cursor Option the same message will be returned.
Thanks |
|
Back to top |
|
 |
mqjeff |
Posted: Tue Oct 04, 2011 1:05 pm Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
vishu_100 wrote: |
Hi Dear , |
that may have been the wrong choice of words.
vishu_100 wrote: |
but the message was deleted from queue after this code run |
Because you missed the important bit about the MQOO option.
Also, you *DO NOT* want to treat a queue as an indexable storage facility.
You *DO NOT* want to treat a queue as if it were anything other than a FIFO structure that you REMOVE messages from.
You *WILL* run into problems if you continue to do this. Particularly if you have the level of experience with MQ you have already demonstrated. |
|
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
|
|
|
|