Author |
Message
|
arunkumar1989 |
Posted: Mon Apr 27, 2015 2:53 am Post subject: Sleep when Queue have message |
|
|
 Voyager
Joined: 21 Nov 2012 Posts: 98 Location: Chennai
|
Hi All,
I wants to check whether the queue have message with similar message
which i`m processing. if the message i wants to sleep for a while.
Could any one help me on this.
Thanks,
Arun _________________ Being in a crowd when you are alone is ignorance. Enlightenment is being alone in a crowd; a feeling of oneness in a crowd. |
|
Back to top |
|
 |
mqjeff |
Posted: Mon Apr 27, 2015 4:46 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
MQ does not let you search a queue based on the contents of messages.
If you want your program to perform a given action on receiving a given action, then you should write your code to identify whether the current message is the right message to perform that action. |
|
Back to top |
|
 |
arunkumar1989 |
Posted: Mon Apr 27, 2015 11:59 pm Post subject: |
|
|
 Voyager
Joined: 21 Nov 2012 Posts: 98 Location: Chennai
|
Not content based ... need to search by message id. If it has same message id should be sleep for some time. If does not have message id it will process continuously. _________________ Being in a crowd when you are alone is ignorance. Enlightenment is being alone in a crowd; a feeling of oneness in a crowd. |
|
Back to top |
|
 |
iibmate |
Posted: Tue Apr 28, 2015 12:46 am Post subject: |
|
|
 Apprentice
Joined: 17 Mar 2015 Posts: 38 Location: Perth, WA
|
arunkumar1989 wrote: |
need to search by message id. If it has same message id should be sleep for some time. If does not have message id it will process continuously. |
Below answer matches your query.
mqjeff wrote: |
If you want your program to perform a given action on receiving a given action, then you should write your code to identify whether the current message is the right message to perform that action. |
|
|
Back to top |
|
 |
mqjeff |
Posted: Tue Apr 28, 2015 5:07 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
If you simply want to WAIT until a message with a specific message id is on the queue, then you should use an MQGet node that is set to match the message ID.
This is basic MQ programming and basic IIB flow development. |
|
Back to top |
|
 |
zpat |
Posted: Tue Apr 28, 2015 6:22 am Post subject: |
|
|
 Jedi Council
Joined: 19 May 2001 Posts: 5866 Location: UK
|
MQ is fundamentally event driven.
You should unconditionally process messages as they arrive on the queue in most cases (especially in WMB or IIB flows).
Unless you have just sent a request and want to see the reply to it (on a non-dedicated queue).
MQ can only wait on content for you when the selection is by msgid or correlid matching.
Otherwise you are looking at polling and browsing the queue (or using JMS selectors). None of which are particularly efficient but if used carefully can be OK - don't poll too frequently though.
WMB/IIB does not have a browse queue input node. It might be possible to use the JMS input node with a selector (I've never tried).
The MQGET node cannot be used to start a message flow.
It sounds like your requirements are wrong - or your approach to meeting them is fundamentally wrong.
Consider processing all messages in a flow and storing them into a database table.
Then you might use a database trigger or something like that. _________________ 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 |
|
 |
Vitor |
Posted: Tue Apr 28, 2015 10:25 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
arunkumar1989 wrote: |
Not content based ... need to search by message id. If it has same message id should be sleep for some time. If does not have message id it will process continuously. |
This sounds a lot like the messages have an id with some business meaning, i.e. if you have a message with an id "IBMSharePrice" n seconds after the last message with "IBMSharePrice" you sleep (and what I wonder happens to that message?) but if it has "MicrosoftSharePrice" you process it.
This is a very bad design choice.
You should read all the messages as they arrive, put this kind of content in the payload and then evaluate if you want to process it or ignore it. As other posters have correctly pointed out. _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
smdavies99 |
Posted: Tue Apr 28, 2015 10:59 am Post subject: |
|
|
 Jedi Council
Joined: 10 Feb 2003 Posts: 6076 Location: Somewhere over the Rainbow this side of Never-never land.
|
Vitor wrote: |
This sounds a lot like the messages have an id with some business meaning, i.e. if you have a message with an id "IBMSharePrice" n seconds after the last message with "IBMSharePrice" you sleep (and what I wonder happens to that message?) but if it has "MicrosoftSharePrice" you process it.
|
Sound like an excellent Pub/Sub solution to me.... _________________ WMQ User since 1999
MQSI/WBI/WMB/'Thingy' User since 2002
Linux user since 1995
Every time you reinvent the wheel the more square it gets (anon). If in doubt think and investigate before you ask silly questions. |
|
Back to top |
|
 |
Vitor |
Posted: Tue Apr 28, 2015 11:14 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
smdavies99 wrote: |
Vitor wrote: |
This sounds a lot like the messages have an id with some business meaning, i.e. if you have a message with an id "IBMSharePrice" n seconds after the last message with "IBMSharePrice" you sleep (and what I wonder happens to that message?) but if it has "MicrosoftSharePrice" you process it.
|
Sound like an excellent Pub/Sub solution to me.... |
But didn't want to muddy the waters by suggesting it. _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
iibmate |
Posted: Tue Apr 28, 2015 7:18 pm Post subject: |
|
|
 Apprentice
Joined: 17 Mar 2015 Posts: 38 Location: Perth, WA
|
How about this ......
(1) Browse message from queue using MQInput node
(2) Check if message id equal to message id in context queue using MQGet node
(3) If matches, browse from context queue , send to out and in compute node, sleep and no message processing
(4) If no matching, then process message
Environment should be IIB v9 / IIB v10 and MQ v 7.5 / 8.0. |
|
Back to top |
|
 |
mqjeff |
Posted: Wed Apr 29, 2015 4:28 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
iibmate wrote: |
How about this ......
(1) Browse message from queue using MQInput node
(2) Check if message id equal to message id in context queue using MQGet node
(3) If matches, browse from context queue , send to out and in compute node, sleep and no message processing
(4) If no matching, then process message |
Make sure to deploy one message flow instance for each expected sleep.
Or accept that the sleep in one instance of a message flow can interrupt the processing of other messages.
Or send the matching message to a timeout control node...
http://www.ibm.com/developerworks/websphere/library/techarticles/0603_schutz/0603_schutz.html |
|
Back to top |
|
 |
|