Author |
Message
|
mquser01 |
Posted: Mon Mar 24, 2008 4:13 am Post subject: Asynchronously receive message |
|
|
Acolyte
Joined: 06 Mar 2008 Posts: 52
|
I want to get message asynchrously.
Does MQseries provide any such functionality that allows us to receive messages asynchronously?
is there any equivalent for MSMQ PMQRECEIVECALLBACK in MQSeries?
Please help... |
|
Back to top |
|
 |
Gaya3 |
Posted: Mon Mar 24, 2008 4:21 am Post subject: |
|
|
 Jedi
Joined: 12 Sep 2006 Posts: 2493 Location: Boston, US
|
Yes sure..
MQ Supports both asynchrnous and synchronous messages
let me point out here, it works better than MSMQ....
IBM MQ is platform independent
Regards
gayathri _________________ Regards
Gayathri
-----------------------------------------------
Do Something Before you Die |
|
Back to top |
|
 |
mquser01 |
Posted: Mon Mar 24, 2008 5:06 am Post subject: |
|
|
Acolyte
Joined: 06 Mar 2008 Posts: 52
|
thanks for the prompt reply. please let me know the MQAPI used for receiving messages asynchronously..
does anyone have a sample code used for receiving messages asynchronously or link to any reading material for the same? |
|
Back to top |
|
 |
jefflowrey |
Posted: Mon Mar 24, 2008 5:09 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
The API used to receive an asynchronous message is MQGET.
The API used to receive a synchronous message is MQGET.
Please spend five minutes looking for the Application Programming Guide in the MQ Information Center. _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
rtsujimoto |
Posted: Mon Mar 24, 2008 9:28 am Post subject: |
|
|
Centurion
Joined: 16 Jun 2004 Posts: 119 Location: Lake Success, NY
|
I took a quick look at the MSMQ PMQRECEIVECALLBACK description and there's good news and then there's bad news. The good news is that MQ's asynchronous message retrieval is similar to MSMQ in some respects. The bad news is some of that functionality only exists on z/OS.
As per MS:
When asynchronously reading messages, MQReceiveMessage returns a SUCCESS value if a suitable message is found.
Otherwise, the function returns immediately with the return value MQ_INFORMATION_OPERATION_PENDING. This return value indicates that the operation is pending and will be completed as soon as a suitable message can be found.
Asynchronous receive is based on standard Microsoft® Win32® mechanisms.
To read messages asynchronously, applications can use one of the following:
A callback function
A Windows Event mechanism
A completion port
When using a callback function, you can register only 64 callbacks at the same time.
Completion ports cannot be used by dependent client applications. On MSMQ independent clients and servers, queue handles are implemented as file handles, which allows them to be associated with completion ports. However, on dependent clients, queue handles are not file handles and as a result cannot be used with completion ports.
Keep the output parameters for an asynchronous call to MQReceiveMessage intact until the operation is complete (that is, until you cannot free or reuse them).
Use automatic variables with caution.
In MQ, if a message is available, you will get it immediately, as you would in MSMQ. If none is available, you would get a 2033 return code (e.g. no message available), which could be treated the same as "operation pending". But, the support for asynchronous notification of a suitable message only exists in z/OS, e.g. MQGET with the Signal option. Plus, the program issuing this request must be in assembler. |
|
Back to top |
|
 |
jefflowrey |
Posted: Mon Mar 24, 2008 9:44 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
|
Back to top |
|
 |
Vitor |
Posted: Mon Mar 24, 2008 11:06 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
jefflowrey wrote: |
EDIT: I'm feeling nice.
|
Happy Easter to all our readers  _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
mquser01 |
Posted: Mon Mar 24, 2008 8:22 pm Post subject: |
|
|
Acolyte
Joined: 06 Mar 2008 Posts: 52
|
as mentioned by rtsujimoto MQGET supports functionality of notification as in MSMQ but this is restricted to z/OS platform and i am working on Linux in C++, so what do i do?? |
|
Back to top |
|
 |
zpat |
Posted: Mon Mar 24, 2008 11:37 pm Post subject: |
|
|
 Jedi Council
Joined: 19 May 2001 Posts: 5866 Location: UK
|
I think you are asking, "how can I have a program invoked on arrival of a message rather than waiting for it to arrive"?
Call back processing is very low level, MQ is cross-platform so no surprise that this is not a standard MQI feature.
Triggering is the answer. But don't use this for high volume messaging. |
|
Back to top |
|
 |
mquser01 |
Posted: Tue Mar 25, 2008 1:18 am Post subject: |
|
|
Acolyte
Joined: 06 Mar 2008 Posts: 52
|
yup you guessed it right i don't want the program to wait for messages to arrive also no of messages i am handling is large in volume.
i want a notification when message arrives so that i can call another function as i can do using callback function in MSMQ i.e. PMQRECEIVECALLBACK ... Is there any way out??? Does MQ provide any support for this functionality --- on Linux in C++??
Last edited by mquser01 on Tue Mar 25, 2008 7:49 pm; edited 1 time in total |
|
Back to top |
|
 |
jefflowrey |
Posted: Tue Mar 25, 2008 1:42 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
I'm really confused.
You're migrating from MSMQ to C on Linux?
There isn't an equivalent of the .NET Monitor in C. The Java equivalent is an MDB. An MDB just uses a separate thread (in the app server, that you don't have to write) that will sit on MQGET and invoke your own code when a message arrives.
This isn't that hard to write on your own, in C that you can run on Linux.
You can also look at XMS for C/C++. _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
Vitor |
Posted: Tue Mar 25, 2008 1:42 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
mquser01 wrote: |
i want a notification when message arrives so that i can call another function as i can do using callback function in MSMQ i.e. PMQRECEIVECALLBACK ... Is there any way out??? Does MQ provide any support for this functionality --- on Linux in C++?? |
Triggering is the only Linux mechanism for notification of message receipt, and you don't want to be triggered on every message if the message volume is large.
It's not a big thing to implement a C++ app that calls your function on the arrival of each message, but IMHO you'll need to implement it yourself via an app. _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
fjb_saper |
Posted: Tue Mar 25, 2008 2:23 am Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
jefflowrey wrote: |
I'm really confused.
You're migrating from MSMQ to C on Linux?
There isn't an equivalent of the .NET Monitor in C. The Java equivalent is an MDB. An MDB just uses a separate thread (in the app server, that you don't have to write) that will sit on MQGET and invoke your own code when a message arrives.
This isn't that hard to write on your own, in C that you can run on Linux.
You can also look at XMS for C/C++. |
Remember to look into the XMS support pack that Jeff mentioned here.
It will allow you to use JMS like functionality in C/C++ and will exactly do what you're looking for...(check for message listener functionality)
Enjoy  _________________ MQ & Broker admin |
|
Back to top |
|
 |
mquser01 |
Posted: Wed Mar 26, 2008 11:03 pm Post subject: XMS |
|
|
Acolyte
Joined: 06 Mar 2008 Posts: 52
|
as suggested i have installed XMS on my machine and was going through the pdf in the installation package.
can any one please give me brief idea on what exactly is XMS and when is it used ?
Also please let me know to understand the concept of XMS where should i start from?? I have never used JMS so i don't know anything about JMS functionality whose refernce is used in the pdf also... |
|
Back to top |
|
 |
Vitor |
Posted: Thu Mar 27, 2008 1:41 am Post subject: Re: XMS |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
mquser01 wrote: |
can any one please give me brief idea on what exactly is XMS and when is it used ? |
XMS is a JMS implementation for non-Java applications.
mquser01 wrote: |
Also please let me know to understand the concept of XMS where should i start from?? I have never used JMS so i don't know anything about JMS functionality whose refernce is used in the pdf also... |
Start from JMS. Any of the reference works on JMS (Mr Google will be happy to help with finding those) will illustrate XMS. _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
|