Author |
Message
|
Prasi |
Posted: Tue Apr 11, 2017 6:05 am Post subject: Issue when getting messages matching the group Id. |
|
|
Apprentice
Joined: 03 Aug 2011 Posts: 42
|
Hi,
I am trying to send an MQ message which should search another queue (say IN). The incoming MQ message' Group Id should be used in searching the IN queue's group id. If found, it should be deleted from the queue.
I am not able to delete the message with matching group id. instead it deletes some other message from the queue. What is that I am missing. I have searched the forum's but couldnt exactly find what is missing. Any help is appreciated. Thanks in advance.
This is the code i have written:
Code: |
String qmgrName = getBroker().getQueueManagerName();
MQQueueManager qmgr = new MQQueueManager(qmgrName);
int openOptions= CMQC.MQOO_FAIL_IF_QUIESCING |CMQC.MQOO_INPUT_SHARED |CMQC.MQOO_BROWSE;
MQQueue queue = qmgr.accessQueue("IN", openOptions);
MQMessage theMessage = new MQMessage(); MQGetMessageOptions gmo = new MQGetMessageOptions();
gmo.matchOptions = CMQC.MQGMO_BROWSE_FIRST |CMQC.MQMO_MATCH_GROUP_ID;
boolean x=true;
while(x)
{
try{
int status =0;
if (status ==0)
{
queue.get(theMessage, gmo);
gmo.options = CMQC.MQGMO_MSG_UNDER_CURSOR ;
gmo.options =CMQC.MQGMO_BROWSE_NEXT;
}
}catch(MQException e)
{ if(e.reasonCode == 2033)
{
System.out.println("no more message available or retrived");
}
x=false;
}
}
queue.close();
qmgr.disconnect(); |
|
|
Back to top |
|
 |
mqjeff |
Posted: Tue Apr 11, 2017 6:12 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
...why are you browsing them first? If you want to process them and then delete them, just plain get them.
Also, every time you think of "searching a queue" you should find a different solution. _________________ chmod -R ugo-wx / |
|
Back to top |
|
 |
bruce2359 |
Posted: Tue Apr 11, 2017 6:55 am Post subject: |
|
|
 Poobah
Joined: 05 Jan 2008 Posts: 9469 Location: US: west coast, almost. Otherwise, enroute.
|
Research MQMO ( MQ match options) with MQGET. _________________ I like deadlines. I like to wave as they pass by.
ב''ה
Lex Orandi, Lex Credendi, Lex Vivendi. As we Worship, So we Believe, So we Live. |
|
Back to top |
|
 |
Prasi |
Posted: Tue Apr 11, 2017 6:59 am Post subject: |
|
|
Apprentice
Joined: 03 Aug 2011 Posts: 42
|
@bruce2359, I am already matching it using MQC.MQMO_MATCH_GROUP_ID. |
|
Back to top |
|
 |
bruce2359 |
Posted: Tue Apr 11, 2017 7:21 am Post subject: |
|
|
 Poobah
Joined: 05 Jan 2008 Posts: 9469 Location: US: west coast, almost. Otherwise, enroute.
|
Prasi wrote: |
@bruce2359, I am already matching it using MQC.MQMO_MATCH_GROUP_ID. |
Ooooops. _________________ I like deadlines. I like to wave as they pass by.
ב''ה
Lex Orandi, Lex Credendi, Lex Vivendi. As we Worship, So we Believe, So we Live. |
|
Back to top |
|
 |
Vitor |
Posted: Tue Apr 11, 2017 7:32 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
mqjeff wrote: |
...why are you browsing them first? If you want to process them and then delete them, just plain get them. |
mqjeff wrote: |
Also, every time you think of "searching a queue" you should find a different solution. |
I'd also question the use of group id for this. I think you might be hitting a problem with incomplete groups or similar; why not use correlation id?
But as my most worthy associate correctly points out, if the answer is "search the queue" then you need a different question. Also be aware that the browse operation is the most inefficient and resource intensive MQ operation. If this is a low-SLA operation, you're likely to run into problems as you scale even if you get it working. _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
fjb_saper |
Posted: Tue Apr 11, 2017 7:36 am Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
Why are you trying to do this in the broker the way you are doing it?
Check out the MQ Input node and its capabilities to read messages in group...
You could always create a collection with the groupID...
 _________________ MQ & Broker admin |
|
Back to top |
|
 |
Vitor |
Posted: Tue Apr 11, 2017 7:41 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
fjb_saper wrote: |
Why are you trying to do this in the broker the way you are doing it? |
I suspect, despite where the thread has been posted, the OP is using Java. _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
hughson |
Posted: Tue Apr 11, 2017 10:25 pm Post subject: Re: Issue when getting messages matching the group Id. |
|
|
 Padawan
Joined: 09 May 2013 Posts: 1959 Location: Bay of Plenty, New Zealand
|
Prasi wrote: |
This is the code i have written:
Code: |
MQGetMessageOptions gmo = new MQGetMessageOptions();
gmo.matchOptions = CMQC.MQGMO_BROWSE_FIRST |CMQC.MQMO_MATCH_GROUP_ID;
:
gmo.options = CMQC.MQGMO_MSG_UNDER_CURSOR ;
gmo.options =CMQC.MQGMO_BROWSE_NEXT;
|
|
These bits of your code don't look quite right.
You cannot use an MQGMO_ constant in matchOptions. You must ONLY use MQMO_ options.
The value of MQGMO_BROWSE_FIRST is 0x00000010 which is the same as MQMO_MATCH_OFFSET, so you have actually written this:-
Code: |
gmo.matchOptions = CMQC.MQMO_MATCH_OFFSET |CMQC.MQMO_MATCH_GROUP_ID; |
Which may have something to do with your matching going awry?
Because of this error, you are also therefore never setting gmo.options to MQGMO_BROWSE_FIRST ever.
Secondly, if you wanted to set the gmo.options to be both of MQGMO_MSG_UNDER_CURSOR and MQGMO_BROWSE_NEXT you have not managed it, you have over-written the first with the second line.
Review your code for these errors, and try it again.
Cheers
Morag _________________ Morag Hughson @MoragHughson
IBM MQ Technical Education Specialist
Get your IBM MQ training here!
MQGem Software |
|
Back to top |
|
 |
|