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 Index » IBM MQ Java / JMS » How to browse a message using the message ID?

Post new topic  Reply to topic
 How to browse a message using the message ID? « View previous topic :: View next topic » 
Author Message
neliosam
PostPosted: Tue Oct 11, 2016 9:44 am    Post subject: How to browse a message using the message ID? Reply with quote

Novice

Joined: 08 Jan 2007
Posts: 13
Location: Brazil

I am used to browse a queue in the traditional way by looping every single message in the queue.

Now I have a situation where I need to browse a specific message by using the message ID to browse the message and I am a litle lost on how to accomplish this.

When using

MQGMO_BROWSE_FIRST -> This will point the cursor in the first message in the queue (ignore the MQMO_MATCH_MSG_ID directive)

If I remove the browse option I can reach the message (but not browsing).

What option should I use to browse a specific message using the message ID?
_________________
neliosam
MQSeries Certified Administrator
Back to top
View user's profile Send private message Send e-mail
Vitor
PostPosted: Tue Oct 11, 2016 10:54 am    Post subject: Re: How to browse a message using the message ID? Reply with quote

Grand High Poobah

Joined: 11 Nov 2005
Posts: 26093
Location: Texas, USA

neliosam wrote:
I am used to browse a queue in the traditional way by looping every single message in the queue.


Whilst I don't want to trample on your traditions, that's a horrible coding model and not best practice in any non-administrative use case I'm familiar with.

neliosam wrote:
Now I have a situation where I need to browse a specific message by using the message ID to browse the message and I am a litle lost on how to accomplish this.


This still sounds horribly like using a queue as a database. I continue to question your use case.

neliosam wrote:
When using

MQGMO_BROWSE_FIRST -> This will point the cursor in the first message in the queue (ignore the MQMO_MATCH_MSG_ID directive)

If I remove the browse option I can reach the message (but not browsing).

What option should I use to browse a specific message using the message ID?


What version of MQ? What application programming language?

Given that this clearly states:

Quote:
You can specify MQGMO_BROWSE_FIRST with any valid combination of the MQGMO_* and MQMO_* options that control the processing of messages in groups and segments of logical messages.


this sounds like a product defect and a PMR, or a hole in your application code you could fly a 747 through.
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
mqjeff
PostPosted: Tue Oct 11, 2016 11:13 am    Post subject: Re: How to browse a message using the message ID? Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

Vitor wrote:
Given that this clearly states:

Quote:
You can specify MQGMO_BROWSE_FIRST with any valid combination of the MQGMO_* and MQMO_* options that control the processing of messages in groups and segments of logical messages.


this sounds like a product defect and a PMR, or a hole in your application code you could fly a 747 through.


I take that to mean "message groups" and "message segmentation" and not "any random combination of MQGMO and MQMO options".

So if you want to get to message ID ABCD, you have to browse all of them, or do a destructive get.

I suspect there would be a sharp impact heard over the phone if you tried to open a PMR.

But this does terribly sound like using a queue as a database and will perform much like a 747 trying to drive down a highway without using it's jet engines.
_________________
chmod -R ugo-wx /
Back to top
View user's profile Send private message
Vitor
PostPosted: Tue Oct 11, 2016 11:25 am    Post subject: Re: How to browse a message using the message ID? Reply with quote

Grand High Poobah

Joined: 11 Nov 2005
Posts: 26093
Location: Texas, USA

mqjeff wrote:
I take that to mean "message groups" and "message segmentation" and not "any random combination of MQGMO and MQMO options".


I take that to mean what it says. Not what (with your insider knowledge of the product) you think it should mean.

mqjeff wrote:
So if you want to get to message ID ABCD, you have to browse all of them, or do a destructive get.


I'm inclined to agree with you, having never tried the daft design the OP is proposing.

mqjeff wrote:
I suspect there would be a sharp impact heard over the phone if you tried to open a PMR.


The sound of one hand slapping? Slapping the guy who wrote the KC article?

If it doesn't work the way the OP wants it to work (because no one should want it to work like that) then it should say so.

mqjeff wrote:
But this does terribly sound like using a queue as a database and will perform much like a 747 trying to drive down a highway without using it's jet engines.




Given that the average 747 will quickly get it's wings stuck on some of the highway fixtures and stop moving.
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
mqjeff
PostPosted: Tue Oct 11, 2016 11:50 am    Post subject: Re: How to browse a message using the message ID? Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

Vitor wrote:
mqjeff wrote:
I take that to mean "message groups" and "message segmentation" and not "any random combination of MQGMO and MQMO options".


I take that to mean what it says. Not what (with your insider knowledge of the product) you think it should mean.


Oh. Ok.

Let's review what it says...
a) You can specify MQGMO_BROWSE_FIRST with

b) any valid combination of the MQGMO_* and MQMO_* options that control the processing of messages in groups and segments of logical messages

Or do you think it says
a) You can specify MQGMO_BROWSE_FIRST with

b) any valid combination of the MQGMO_* and MQMO_* options

c) ???

d) control the processing of mesages in groups and segments of logica messages

e) ???

I think, without any internal knowledge of the product, that you can ues browse first/browse next to start at the beginning (first in) and browse each message until you get to the end (last out). Or you can browse using groups, or using segments. But not browse using a random message id.
_________________
chmod -R ugo-wx /
Back to top
View user's profile Send private message
Vitor
PostPosted: Tue Oct 11, 2016 11:56 am    Post subject: Reply with quote

Grand High Poobah

Joined: 11 Nov 2005
Posts: 26093
Location: Texas, USA

Maybe it's a British thing. I don't see it that way, even if I squint.

This is tangential to the key issue.

Even if you could do this, you shouldn't.

You can drive a 747 down a highway without using engines if you strap enough fireworks to it. Nothing about it is a good idea, but it would work for you.

Not for the other highway users so much, and not for you if the highway wasn't completely straight, wasn't completely flat and wasn't as long as you thought it was.
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
mqjeff
PostPosted: Tue Oct 11, 2016 11:59 am    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

Vitor wrote:
Maybe it's a British thing. I don't see it that way, even if I squint.


Well, I'll shoot leaves, and you can eat them...

Vitor wrote:
This is tangential to the key issue.

Even if you could do this, you shouldn't.

Yes, I agree.

Aside from all of the problematic programming issues, the performance of MQ will get increasingly bad with each message added to the queue.
_________________
chmod -R ugo-wx /
Back to top
View user's profile Send private message
Vitor
PostPosted: Tue Oct 11, 2016 12:03 pm    Post subject: Reply with quote

Grand High Poobah

Joined: 11 Nov 2005
Posts: 26093
Location: Texas, USA

mqjeff wrote:
Vitor wrote:
Maybe it's a British thing. I don't see it that way, even if I squint.


Well, I'll shoot leaves, and you can eat them...


We don't shoot leaves, we boil them alive, throw away their bodies and drink the water. With milk.

For those who wonder if I've laid off the decaff again, see here
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
zpat
PostPosted: Tue Oct 11, 2016 1:26 pm    Post subject: Reply with quote

Jedi Council

Joined: 19 May 2001
Posts: 5849
Location: UK

Leaving my virtual colleagues debates aside for a moment.

You need to bear in mind where your browse cursor is and that the match options search should start from there until the last message.

Unless indexed by message id (z/OS) a large queue may take a long time to search but that doesn't mean it is an invalid model. JMS selectors work in a similar way.

The searching takes place on the QM side, so doesn't send all the messages over the network. It may not be that slow.

To browse and match try just using BROWSE and MATCH. Using BROWSE FIRST is overriding the match (as you say) to position at the first message.

You might want to use browse first to reset your browse cursor. It should all be in the infocenter.
_________________
Well, I don't think there is any question about it. It can only be attributable to human error. This sort of thing has cropped up before, and it has always been due to human error.
Back to top
View user's profile Send private message
PaulClarke
PostPosted: Tue Oct 11, 2016 1:26 pm    Post subject: Reply with quote

Grand Master

Joined: 17 Nov 2005
Posts: 1002
Location: New Zealand

Going back to the original question......

If you issue an MQGMO_BROWSE_FIRST and fill in the MQMD.MessageId with the Id you are looking for then MQ will return the first message on the queue with that Id (remember that Message Ids are not necessarily unique sadly).

So, it is not true to say that MQGMO_BROWSE_FIRST will always give you the first message on the queue, just the first one it finds that math your other selection criteria.

If you have MO71 then you can very easily try this out using the API Exerciser. It can save hours on these types of questions.

Cheers,

Paul.
_________________
Paul Clarke
MQGem Software
www.mqgem.com
Back to top
View user's profile Send private message Visit poster's website
neliosam
PostPosted: Tue Oct 11, 2016 3:29 pm    Post subject: Reply with quote

Novice

Joined: 08 Jan 2007
Posts: 13
Location: Brazil

Hi Gentleman,

Problem is solved guys!


Let me share what the issue was. This is a Java program and I am using the MQ version 8.0.0.5.

I have a personalized Message object that extends the real MQ message. This object was buggy and the message ID was not being updated properly. So when using the match options = MQConstants.MQMO_MATCH_MSG_ID would never works .

Strangely instead of returning a 2033 the first message in the queue was being retrieved and this was when I got confused.

After fixing the messageID the browse operation is working as expected.


Thanks a lot for your assistance,
Nélio
_________________
neliosam
MQSeries Certified Administrator
Back to top
View user's profile Send private message Send e-mail
mqjeff
PostPosted: Wed Oct 12, 2016 3:36 am    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

Why are you browsing these messages?

Are you reinventing any of the hundreds of monitoring tools, both free and paid, that work with MQ?

If so, you are adding a lot more risk to your systems than you might think.
_________________
chmod -R ugo-wx /
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » IBM MQ Java / JMS » How to browse a message using the message 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.