Author |
Message
|
chetandada |
Posted: Wed Sep 12, 2018 4:08 am Post subject: Get continuously message using MQGET |
|
|
Newbie
Joined: 12 Sep 2018 Posts: 7
|
Hi all ,
Below is the function call to get message
MQGET(Hcon, Hobj, &md, &gmo, sizeof(buffer), l_buffer, &messlen, &CompCode, &Reason);
we are getting only one message and after this no message getting.
there are already more than 100 message in queue.
please help to how to get message continuously by MQGET call or is there any command i need to execute?
Thanks in advance. |
|
Back to top |
|
 |
exerk |
Posted: Wed Sep 12, 2018 4:32 am Post subject: |
|
|
 Jedi Council
Joined: 02 Nov 2006 Posts: 6339
|
Put it in a loop...
...and I strongly suggest that you either get some training, or read the MQ Application Programming Guide. _________________ It's puzzling, I don't think I've ever seen anything quite like this before...and it's hard to soar like an eagle when you're surrounded by turkeys. |
|
Back to top |
|
 |
chetandada |
Posted: Wed Sep 12, 2018 4:39 am Post subject: |
|
|
Newbie
Joined: 12 Sep 2018 Posts: 7
|
It is already written in loop |
|
Back to top |
|
 |
Vitor |
Posted: Wed Sep 12, 2018 4:50 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
chetandada wrote: |
It is already written in loop |
So what you're saying is that your code enters the loop, executes the first MQGet call as posted, then loops back, executes the MQGet call again and doesn't return a message?
So what does happen? The call sits endlessly? It returns with a reason code?
Flying monkeys steal your computer? What? _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
exerk |
Posted: Wed Sep 12, 2018 4:54 am Post subject: |
|
|
 Jedi Council
Joined: 02 Nov 2006 Posts: 6339
|
chetandada wrote: |
It is already written in loop |
Then either your logic is flawed, or you are not resetting the MsgId on each GET...
...depending on gmo.Version you're setting (if any).
Take a look at the samples, specifically amqsget0.c, which will help you. _________________ It's puzzling, I don't think I've ever seen anything quite like this before...and it's hard to soar like an eagle when you're surrounded by turkeys. |
|
Back to top |
|
 |
chetandada |
Posted: Wed Sep 12, 2018 5:04 am Post subject: |
|
|
Newbie
Joined: 12 Sep 2018 Posts: 7
|
Vitor wrote: |
chetandada wrote: |
It is already written in loop |
So what you're saying is that your code enters the loop, executes the first MQGet call as posted, then loops back, executes the MQGet call again and doesn't return a message?
So what does happen? The call sits endlessly? It returns with a reason code?
Flying monkeys steal your computer? What? |
yes it doesn't return a message after next call of MQGET |
|
Back to top |
|
 |
Vitor |
Posted: Wed Sep 12, 2018 5:47 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
chetandada wrote: |
yes it doesn't return a message after next call of MQGET |
If the call sits endlessly and doesn't return then it's not finding a suitable message.
My worthy associate points out the typically noob mistake in these circumstances, and I echo all the advice he gives. _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
exerk |
Posted: Wed Sep 12, 2018 5:51 am Post subject: |
|
|
 Jedi Council
Joined: 02 Nov 2006 Posts: 6339
|
Vitor wrote: |
...My worthy associate points out the typically noob mistake in these circumstances, and I echo all the advice he gives. |
I am in very great danger of actually knowing what I'm talking about for once - a scary thought! Probably been hanging around developers for far longer than is good for me . _________________ It's puzzling, I don't think I've ever seen anything quite like this before...and it's hard to soar like an eagle when you're surrounded by turkeys. |
|
Back to top |
|
 |
RogerLacroix |
Posted: Wed Sep 12, 2018 10:36 am Post subject: Re: Get continuously message using MQGET |
|
|
 Jedi Knight
Joined: 15 May 2001 Posts: 3264 Location: London, ON Canada
|
chetandada wrote: |
MQGET(Hcon, Hobj, &md, &gmo, sizeof(buffer), l_buffer, &messlen, &CompCode, &Reason); |
A couple of things:
(1) Why are you using "sizeof(buffer)" but the real buffer "l_buffer" has a different name. That's some bad programming.
(2) Are you clearing the MsgId and CorrelId before each MQGET call?
i.e.
Code: |
memcpy(md.MsgId, MQMI_NONE, sizeof(md.MsgId));
memcpy(md.CorrelId, MQCI_NONE, sizeof(md.CorrelId)); |
Regards,
Roger Lacroix
Capitalware Inc. _________________ Capitalware: Transforming tomorrow into today.
Connected to MQ!
Twitter |
|
Back to top |
|
 |
hughson |
Posted: Wed Sep 12, 2018 2:28 pm Post subject: Re: Get continuously message using MQGET |
|
|
 Padawan
Joined: 09 May 2013 Posts: 1959 Location: Bay of Plenty, New Zealand
|
RogerLacroix wrote: |
chetandada wrote: |
MQGET(Hcon, Hobj, &md, &gmo, sizeof(buffer), l_buffer, &messlen, &CompCode, &Reason); |
Are you clearing the MsgId and CorrelId before each MQGET call?
i.e.
Code: |
memcpy(md.MsgId, MQMI_NONE, sizeof(md.MsgId));
memcpy(md.CorrelId, MQCI_NONE, sizeof(md.CorrelId)); |
|
 _________________ Morag Hughson @MoragHughson
IBM MQ Technical Education Specialist
Get your IBM MQ training here!
MQGem Software |
|
Back to top |
|
 |
chetandada |
Posted: Thu Sep 13, 2018 11:26 pm Post subject: Re: Get continuously message using MQGET |
|
|
Newbie
Joined: 12 Sep 2018 Posts: 7
|
Code works fine after resetting msgid on each MQGET call..
Thank you all |
|
Back to top |
|
 |
bruce2359 |
Posted: Sat Sep 15, 2018 6:19 am Post subject: Re: Get continuously message using MQGET |
|
|
 Poobah
Joined: 05 Jan 2008 Posts: 9469 Location: US: west coast, almost. Otherwise, enroute.
|
chetandada wrote: |
Code works fine after resetting msgid on each MQGET call..
Thank you all |
The documented behavior of MQGET is to retrieve the MQMD (and message payload). On the next MQGET call, if the MQMD MsgId, CorrelId, GroupID, etc. are NOT reset, then the call is asking for another message with these exact same values - not impossible, but highly unlikely. _________________ 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 |
|
 |
rekarm01 |
Posted: Wed Sep 19, 2018 2:59 pm Post subject: Re: Get continuously message using MQGET |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 1415
|
This topic seems better suited for the IBM MQ API Support forum.
chetandada wrote: |
Code works fine after resetting msgid on each MQGET call. |
That is one way to disable selectively matching messages, especially useful for any applications that still need to maintain backwards compatibility with MQSeries queue managers.
exerk wrote: |
Take a look at the samples, specifically amqsget0.c, which will help you. |
Otherwise, applications can set MQGMO Version to MQGMO_VERSION_2 (or greater), and MatchOptions to MQMO_NONE, so as to avoid the need to reset MsgId and CorrelId before each MQGET call. |
|
Back to top |
|
 |
|