Author |
Message
|
yasaboy |
Posted: Wed Jun 25, 2014 7:53 pm Post subject: What is MQCB? |
|
|
Voyager
Joined: 23 Jun 2014 Posts: 90
|
Hi,
Sorry for asking a stupid question like this. Can anyone please explain me what id MQCB and the advantage of using it ? I was looking through the IBM reference but could not grasp the idea of using MQCB.
Thanks in advance  |
|
Back to top |
|
 |
IanAlderson |
Posted: Thu Jun 26, 2014 2:29 am Post subject: |
|
|
Novice
Joined: 23 Apr 2014 Posts: 17
|
Hi,
MQCB (MQ callback) is really for use when your program wants to do other stuff while you're waiting for messages to arrive on a queue(s).
The example I always think of is when an application needs to read messages from multiple input queues. You can use callback to receive a message when it arrives on any of the input queues. Before MQCB the application would typically poll each queue in turn, causing overhead on the Queue Manager regardless of whether messages were available.
If you have a single input queue then typically you would just use a normal mqget with wait (rather than MQCB) and control will be returned to the program when either a message arrives or the specified wait interval expires. This is efficient when using a single queue and there is no delay in receiving the message.
The main thing you want to avoid is repeatedly polling a queue in short intervals.
HTH |
|
Back to top |
|
 |
yasaboy |
Posted: Thu Jun 26, 2014 3:20 am Post subject: |
|
|
Voyager
Joined: 23 Jun 2014 Posts: 90
|
@IanAlderson thank you very much for your reply. I really got the concept now.
IanAlderson wrote: |
Hi,
MQCB (MQ callback) is really for use when your program wants to do other stuff while you're waiting for messages to arrive on a queue(s).
The example I always think of is when an application needs to read messages from multiple input queues. You can use callback to receive a message when it arrives on any of the input queues. Before MQCB the application would typically poll each queue in turn, causing overhead on the Queue Manager regardless of whether messages were available.
If you have a single input queue then typically you would just use a normal mqget with wait (rather than MQCB) and control will be returned to the program when either a message arrives or the specified wait interval expires. This is efficient when using a single queue and there is no delay in receiving the message.
The main thing you want to avoid is repeatedly polling a queue in short intervals.
HTH |
So, I created several MQ's and could create a working code by using callbacks to get the messages of those queues when ever a message arrives to those queues.
Now the problem what is the way to find the name of the MessageQueue from which we received the messages using MQCB? I want to separate the messages by the Queue name. Any suggestions ?
I use the code sample below to display the messages that MQCB receives
Code: |
void MessageConsumer(MQHCONN hConn,
MQMD * pMsgDesc,
MQGMO * pGetMsgOpts,
MQBYTE * Buffer,
MQCBC * pContext)
{
MQLONG i,max;
MQLONG Length;
printf(" From MessageConsumer\n ");
switch(pContext->CallType)
{
case MQCBCT_MSG_REMOVED:
case MQCBCT_MSG_NOT_REMOVED:
max = pGetMsgOpts -> ReturnedLength;
if (max > 200) max = 200;
for (i=0; i<max; i++)
{
if (isprint(Buffer[i])) fputc(Buffer[i],stdout);
else fputc('.',stdout);
}
fputc('\n',stdout);
///sleep(10);
break;
}
} |
|
|
Back to top |
|
 |
IanAlderson |
Posted: Thu Jun 26, 2014 6:07 am Post subject: |
|
|
Novice
Joined: 23 Apr 2014 Posts: 17
|
Try this
Code: |
pGetMsgOpts -> ResolvedQName |
Note that this is the resolved queue name, so if you use an alias then it will contain the base queue that the qalias resolves to. |
|
Back to top |
|
 |
bruce2359 |
Posted: Thu Jun 26, 2014 7:42 am Post subject: |
|
|
 Poobah
Joined: 05 Jan 2008 Posts: 9469 Location: US: west coast, almost. Otherwise, enroute.
|
IanAlderson wrote: |
MQCB (MQ callback) is really for use when your program wants to do other stuff while you're waiting for messages to arrive on a queue(s). |
Your program wanting to do other stuff while you're waiting for messages to arrive on a queue is behavior I'd expect to see in a multi-threading server-type application.
IanAlderson wrote: |
The example I always think of is when an application needs to read messages from multiple input queues. |
... and the application cannot predict (or doesn't care) into which queue a message will arrive first/next. _________________ 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 |
|
 |
yasaboy |
Posted: Thu Jun 26, 2014 11:57 am Post subject: |
|
|
Voyager
Joined: 23 Jun 2014 Posts: 90
|
IanAlderson wrote: |
Try this
Code: |
pGetMsgOpts -> ResolvedQName |
Note that this is the resolved queue name, so if you use an alias then it will contain the base queue that the qalias resolves to. |
IanAlderson thanks mate. It really worked and exactly what I was looking for.. Many thanks  |
|
Back to top |
|
 |
gbaddeley |
Posted: Sun Jun 29, 2014 3:57 pm Post subject: |
|
|
 Jedi Knight
Joined: 25 Mar 2003 Posts: 2538 Location: Melbourne, Australia
|
MQCB feature is introduced in section 6.4 of IBM Redbook "WebSphere MQ V7.0 New Features and Enhancements". _________________ Glenn |
|
Back to top |
|
 |
|