ASG
IBM
Zystems
Cressida
Icon
Netflexity
 
  MQSeries.net
Search  Search       Tech Exchange      Education      Certifications      Library      Info Center      SupportPacs      LinkedIn  Search  Search                                                                   FAQ  FAQ   Usergroups  Usergroups
 
Register  ::  Log in Log in to check your private messages
 
RSS Feed - WebSphere MQ Support RSS Feed - Message Broker Support

MQSeries.net Forum IndexWebSphere Message Broker SupportIssue when getting messages matching the group Id.

Post new topicReply to topic
Issue when getting messages matching the group Id. View previous topic :: View next topic
Author Message
Prasi
PostPosted: Tue Apr 11, 2017 6:05 am Post subject: Issue when getting messages matching the group Id. Reply with quote

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
View user's profile Send private message
mqjeff
PostPosted: Tue Apr 11, 2017 6:12 am Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17250

...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.
_________________
Read, Think, Try, Repeat
Back to top
View user's profile Send private message
bruce2359
PostPosted: Tue Apr 11, 2017 6:55 am Post subject: Reply with quote

Poobah

Joined: 05 Jan 2008
Posts: 7777
Location: US: west coast, almost. Otherwise, enroute.

Research MQMO ( MQ match options) with MQGET.
_________________
I didn't know that Schrdinger had a cat.
Back to top
View user's profile Send private message
Prasi
PostPosted: Tue Apr 11, 2017 6:59 am Post subject: Reply with quote

Apprentice

Joined: 03 Aug 2011
Posts: 42

@bruce2359, I am already matching it using MQC.MQMO_MATCH_GROUP_ID.
Back to top
View user's profile Send private message
bruce2359
PostPosted: Tue Apr 11, 2017 7:21 am Post subject: Reply with quote

Poobah

Joined: 05 Jan 2008
Posts: 7777
Location: US: west coast, almost. Otherwise, enroute.

Prasi wrote:
@bruce2359, I am already matching it using MQC.MQMO_MATCH_GROUP_ID.

Ooooops.
_________________
I didn't know that Schrdinger had a cat.
Back to top
View user's profile Send private message
Vitor
PostPosted: Tue Apr 11, 2017 7:32 am Post subject: Reply with quote

Grand High Poobah

Joined: 11 Nov 2005
Posts: 24326
Location: Ohio, 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
View user's profile Send private message
fjb_saper
PostPosted: Tue Apr 11, 2017 7:36 am Post subject: Reply with quote

Grand Poobah

Joined: 18 Nov 2003
Posts: 19147
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
View user's profile Send private message Send e-mail
Vitor
PostPosted: Tue Apr 11, 2017 7:41 am Post subject: Reply with quote

Grand High Poobah

Joined: 11 Nov 2005
Posts: 24326
Location: Ohio, 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
View user's profile Send private message
hughson
PostPosted: Tue Apr 11, 2017 10:25 pm Post subject: Re: Issue when getting messages matching the group Id. Reply with quote

Yatiri

Joined: 09 May 2013
Posts: 680
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
MQGem Software
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:
Post new topicReply to topic Page 1 of 1

MQSeries.net Forum IndexWebSphere Message Broker SupportIssue when getting messages matching the group Id.
Jump to:



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
Protected by Anti-Spam ACP


Theme by Dustin Baccetti
Powered by phpBB 2001, 2002 phpBB Group

Copyright MQSeries.net. All rights reserved.