File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes EJB and other Java EE Technologies and the fly likes jms queue fetching of message as and when it is posted in asynchronous communication Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "jms queue fetching of message as and when it is posted in asynchronous communication" Watch "jms queue fetching of message as and when it is posted in asynchronous communication" New topic
Author

jms queue fetching of message as and when it is posted in asynchronous communication

anish reddy
Ranch Hand

Joined: Apr 19, 2008
Posts: 74
i want to know how to fetch a message from a jms queue when it is posted in asynchronous communication between sender and receiver.

ie how to fetch message by using receive method of messageConusmer.
Samanthi perera
Ranch Hand

Joined: Jan 08, 2010
Posts: 510
before fetch you must send messages
this Servlet shows how to send messages


the this Message Driven Bean shows how to fetch


i think you should follow this tutorials is better.

http://weblogs.java.net/blog/kalali/archive/2006/05/step_by_step_to.html
it gives step by step examples.
anyway it is bit old tutorials.But no problem.

Ralph Jaus
Ranch Hand

Joined: Apr 27, 2008
Posts: 342
Hi Anish,

an example for using MesageConsumer.receive() is provided by the following code excerpt: Hope this helps.


SCJP 5 (98%) - SCBCD 5 (98%)
ramprasad madathil
Ranch Hand

Joined: Jan 24, 2005
Posts: 489

Besides the code posted, there is an important paradigm to understand.

A 'receive' will deliver the next message in the destination. So if there are say 'n' messages, you have to wrap the call to receive in a loop. And finally when there is no message in the queue, this will block till the next message arrives. You can of course chose to specify a timeout value after which the receive returns.

If that is not desirable, you can instead make a call to receiveNoWait() which returns null if there is no more messages to be read. By checking for the return value, you can exit the loop.

To receive the message again after a time interval, it is necessary to invoke receive() again.

A MessageListener on the other hand receives messages continously from the destination. The 'looping' is done internally the jms runtime on the client.

ram.

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: jms queue fetching of message as and when it is posted in asynchronous communication
 
Similar Threads
how to poll a jms queue or topic for message using asynchronous communication
JMS What is Synchronous and which is asynchronous
More resources for tier architecture?
Web service implementaion using MDB for MOM
what is mq skills