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 » General IBM MQ Support » What is MQCB?

Post new topic  Reply to topic
 What is MQCB? « View previous topic :: View next topic » 
Author Message
yasaboy
PostPosted: Wed Jun 25, 2014 7:53 pm    Post subject: What is MQCB? Reply with quote

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
View user's profile Send private message
IanAlderson
PostPosted: Thu Jun 26, 2014 2:29 am    Post subject: Reply with quote

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
View user's profile Send private message
yasaboy
PostPosted: Thu Jun 26, 2014 3:20 am    Post subject: Reply with quote

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
View user's profile Send private message
IanAlderson
PostPosted: Thu Jun 26, 2014 6:07 am    Post subject: Reply with quote

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
View user's profile Send private message
bruce2359
PostPosted: Thu Jun 26, 2014 7:42 am    Post subject: Reply with quote

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
View user's profile Send private message
yasaboy
PostPosted: Thu Jun 26, 2014 11:57 am    Post subject: Reply with quote

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
View user's profile Send private message
gbaddeley
PostPosted: Sun Jun 29, 2014 3:57 pm    Post subject: Reply with quote

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
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 » General IBM MQ Support » What is MQCB?
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.