Author |
Message
|
team |
Posted: Thu Jul 05, 2007 5:40 am Post subject: MQC.MQWI_UNLIMITED |
|
|
Centurion
Joined: 03 Nov 2006 Posts: 108
|
Hi,
A confirmation on the getmessage options, please can you help:
My getMessage function is as follows:
----------------------------------------------------------------------------
getMessage = new MQMessage();
// Set the open options
int openOptions = MQC.MQOO_INPUT_SHARED | MQC.MQOO_FAIL_IF_QUIESCING;
getQueue = qMgr.accessQueue(strQueuename, openOptions);
MQGetMessageOptions getOptions = new MQGetMessageOptions();
// Set up our options to get the first message
getOptions.options = MQC.MQGMO_WAIT + MQC.MQGMO_CONVERT | MQC.MQGMO_SYNCPOINT;
getOptions.waitInterval = MQC.MQWI_UNLIMITED;
// Reset the message and IDs to be empty
getMessage.clearMessage();
getMessage.correlationId = MQC.MQCI_NONE;
getMessage.messageId = MQC.MQMI_NONE;
// Retrieve the message from the queue
getQueue.get(getMessage, getOptions);
---------------------------------------------------------------------------
I wanted to know, in the following scenario where in the queue has one message, do i assume that in a call to the method this message is retrieved?
there after, it waits. Once we have anotehr message on the queue, this is automatically picked up (even though we dont call the function explicityly)
In the sense I wont poll the queue again and again.
Thanks in advance |
|
Back to top |
|
 |
jefflowrey |
Posted: Thu Jul 05, 2007 5:47 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
You only ever get one message for each time you call Get. You will never get any messages if you don't call Get.
The WaitInterval option controls how long the Get will block your code, if there are no messages available.
In the case of MQWI_UNLIMITED, the get will never return, unless a message is there.
In no case, ever, will another message be retrieved after a Get returns - UNLESS you call Get again.
"Don't poll the queue" means "don't issue an MQGet with *no* wait, repeatedly". It doesn't mean "don't issue an MQGet more than once in any situation". _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
team |
Posted: Thu Jul 05, 2007 6:06 am Post subject: |
|
|
Centurion
Joined: 03 Nov 2006 Posts: 108
|
Thanks Jeff.
I have gone away disappointed from this forum. Thanks you all of u.
Just this one more question, then how do I loop on the queues, in the sense, what should my loopin condition be........
in the sense consider a scenario
Initail : 10 msgs
call get 10 times
Wait.....
Message 11 arrives
Call get once more
Waitt..
What shud be loop condition around get...how can i determine that.
Thanks in advance |
|
Back to top |
|
 |
Vitor |
Posted: Thu Jul 05, 2007 6:07 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
team wrote: |
I have gone away disappointed from this forum. Thanks you all of u. |
Sometimes life is just plain unfair.
team wrote: |
What shud be loop condition around get...how can i determine that. |
Loop until no more messages or application ordered to shutdown. Check the reason code from the get. You'll find this construction in most if not all of the IBM supplied sample code.
Do not attempt to count the messages on the queue and loop that many times. _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
team |
Posted: Thu Jul 05, 2007 6:13 am Post subject: |
|
|
Centurion
Joined: 03 Nov 2006 Posts: 108
|
Oh nuh!!
My big mistake...!!!!!
I wanted to write I have never gone away diappointed...sincere apologies guys!!
Thanks again...
Silly me!!! |
|
Back to top |
|
 |
team |
Posted: Thu Jul 05, 2007 6:15 am Post subject: |
|
|
Centurion
Joined: 03 Nov 2006 Posts: 108
|
My problem is that....the message can arrive at any point in time.....at distant intervals...
Hence, looping for no messages at any point would not be gud, isn't it. |
|
Back to top |
|
 |
jefflowrey |
Posted: Thu Jul 05, 2007 6:26 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
If you have long periods of time between messages (once an hour or more), then you should be using triggering and not a listener pattern.
Otherwise, the pattern should be something like
-loop until 'quit'
--loop until a 2033
---issue an MQGet with a short wait time
---process message
--end loop
--issue an MQGet with a long wait time
--if 2033, then quit
--else process message
-end loop
Where a "short" wait time might be 1 minute, and a long wait time might be ten minutes.
In all cases, the Get will return *immediately* when a message is available. The wait time is the MAX time it will wait, not the MIN time it will wait. _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
Vitor |
Posted: Thu Jul 05, 2007 6:28 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
team wrote: |
My problem is that....the message can arrive at any point in time.....at distant intervals...
Hence, looping for no messages at any point would not be gud, isn't it. |
So your application is likely to to need quite a long wait interval, or wait unlimited as you are & provide a mechanism for shutting it down when it needs to (end of day, machine reboot, etc). Or triggered when it needs to be.
It's a design decision you need to make. Personally, I favor wait intervals but that's not to say I don't understand the other model, or see how it's better in some circumstances. In which case I'd use it. _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
team |
Posted: Thu Jul 05, 2007 11:40 pm Post subject: |
|
|
Centurion
Joined: 03 Nov 2006 Posts: 108
|
so do you see any problems in:
while(true)
{
perform MQ operations
getOptions.options = MQC.MQGMO_WAIT + MQC.MQGMO_CONVERT | MQC.MQGMO_SYNCPOINT;
getOptions.waitInterval = MQC.MQWI_UNLIMITED;
getMessage.....
} |
|
Back to top |
|
 |
team |
Posted: Thu Jul 05, 2007 11:57 pm Post subject: |
|
|
Centurion
Joined: 03 Nov 2006 Posts: 108
|
Also, just on the thoughts of terminating this process.
Suppose a scenario where in, i would need to terminate the process once in a day, say eod.
If i decide, that persence of a stop-process.file shud terminate the process. How can I expect myprogram that gets the message to check the presence of the file ( while in a wait stage)
Regards,
team |
|
Back to top |
|
 |
Vitor |
Posted: Fri Jul 06, 2007 12:36 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
IMHO you have 3 options:
1) Send your application a message (typically a feedback message to differentiate it from normal traffic), on receipt of which your application closes;
2) Set the wait interval to be the longest period you can tollerate the application not closing, and add code so that it checks for this file before it starts another wait;
3) Code FAIL_IF_QUIESCING and close the queue manager.
This list is not exhaustive, other methods are equally valid though some are more silly, etc, etc. _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
|