Win a copy of Zero to AI - A non-technical, hype-free guide to prospering in the AI era this week in the Artificial Intelligence and Machine Learning forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Paul Clapham
  • Bear Bibeault
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Jj Roberts
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • salvin francis
  • Scott Selikoff
  • fred rosenberger

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

 
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 510
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

 
Ranch Hand
Posts: 342
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Anish,

an example for using MesageConsumer.receive() is provided by the following code excerpt: Hope this helps.
 
Ranch Hand
Posts: 489
Eclipse IDE Tomcat Server Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

 
Right! We're on it! Let's get to work tiny ad!
the value of filler advertising in 2020
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic