Author |
Message
|
jmw |
Posted: Tue Apr 26, 2005 9:14 pm Post subject: Asychronous messaging. |
|
|
Novice
Joined: 16 Apr 2003 Posts: 19
|
Hi All,
Can I using MQ for java base class to do asychronous messaging? just like onMessage does in MQ for JMS?
Thanks. |
|
Back to top |
|
 |
bduncan |
Posted: Tue Apr 26, 2005 11:22 pm Post subject: |
|
|
Padawan
Joined: 11 Apr 2001 Posts: 1554 Location: Silicon Valley
|
If you are using MQSeries as your transport layer, whether you are using JMS or MQI, your messages will always be put asynchronously. That is an inerhent property of MQSeries. _________________ Brandon Duncan
IBM Certified MQSeries Specialist
MQSeries.net forum moderator |
|
Back to top |
|
 |
jefflowrey |
Posted: Wed Apr 27, 2005 3:41 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
What brandon says is technically correct, but mostly orthogonal to your actual question.
It's a very good answer...
What environment are you writing in? What problem are you trying to solve?
You can write your own message listener using the MQ API for Java. All of the sample programs that actually get messages count as message listeners.
You need to be careful in some environments - like inside a j2EE container - to ensure that you don't block other things from happening and that you don't create a transactional event inside a non-XA process that already has another transaction... _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
jmw |
Posted: Wed Apr 27, 2005 4:46 am Post subject: |
|
|
Novice
Joined: 16 Apr 2003 Posts: 19
|
I want the application listening on a queue, it be notified when a message arriving on the queue. |
|
Back to top |
|
 |
jefflowrey |
Posted: Wed Apr 27, 2005 4:51 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
MQ@net wrote: |
I want the application listening on a queue, it be notified when a message arriving on the queue. |
You issue a get and specify a wait time.
Or you use triggering.
You should look at the Application Programming Guide. _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
jmw |
Posted: Wed Apr 27, 2005 5:16 am Post subject: |
|
|
Novice
Joined: 16 Apr 2003 Posts: 19
|
Thanks for you reply. But, if using "get", it is still syncronous, as the applicattion has to wait till the certain amout of wait time passed, during this period of time, the application can not do anything else.
What I am looking for in Base class is, somethin like the onMessage() interface in JMS. It notified when message come. |
|
Back to top |
|
 |
malammik |
Posted: Wed Apr 27, 2005 6:01 am Post subject: |
|
|
 Partisan
Joined: 27 Jan 2005 Posts: 397 Location: Philadelphia, PA
|
onMessage() would only work on J2EE implementation that supports MDBs. WebSphere runs the mq listener which underneath the covers does get with a wait on the queue and when the message arrives it envokes your bean and passet it the message content in the buffer.
Synchronous and Asynchronous need to be viewed in at least two contexts. Logical and Physical. Here is a good example of how a truly asynchronous application is appears to be entirely synchronous to an outsider.
Application W is a java wrapper that communicates with .NET clients via some xml, web services, etc. .NET clients send subscription requests to the wrapper. Wrapper converts the xml into jms subscribe call. Now at this point wrapper can reply back to .NET saying I subscribed you but no he waits for the broker to reply confirming the subscription request. And only then gives back the control to .NET app. This whole time .NET was thinking it was performing a synchronous operation and logically it was however wrapper performed two physical asynchronous requests requested subscription and sending back the reply.
The only thing that I can recommend, it write your own listener and write your own threaded message processor and have the listener invoke whatever method of ur processor interface when the message arrives. Bottom line is somebody's got to have the queue open all the times. Whether it is a listener that's part of WAS or some other j2ee server or your own listener.
Hth. _________________ Mikhail Malamud
http://www.netflexity.com
http://groups.google.com/group/qflex |
|
Back to top |
|
 |
jefflowrey |
Posted: Wed Apr 27, 2005 6:31 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
Your main application doesn't have to "wait" until the message arrives.
Just put your message listening subsystem in a different thread.
And don't use the connection handle in your main processing. _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
|