What is the difference between using receive() method of TopicSubscriber and using a MessageListener to read the messages?
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   rama_krishna
Posted On:   Wednesday, July 24, 2002 04:56 AM

What is the difference between using receive() method of TopicSubscriber and using a MessageListener to read the messages?

I understand that the former is synchronous and the later is asynchronous, but my question how will their implementation differ? Will receive() internally use message listener to receive messages? Will there be any performance drawback if I use receive() method to receive messages? Which is recommended way of usage?

Can any one please throw some light on these questions.

Re: What is the difference between using receive() method of TopicSubscriber and using a MessageListener to read the messages?

Posted By:   Gautam_Marwaha  
Posted On:   Wednesday, July 24, 2002 05:47 AM

You are correct. A TopicSubscriber can receive messages synchronously while implementations of MessageListener (like MDB) will receive messages asynchronously. Their usage is pretty clear - it depends on how you want your message consumer to behave or its lifetime. If you want to receive messages synchronously (block till a message comes along/timeout if dos not come within certain time) use TopicSubscriber OR asynchronously (do something with the message whenever it comes along) use MessageListener. Rule of thumb is that if you are not sure how soon or when a message may come along, use MessageListener. Otherwise if you are sure a message will come along (request/response kind of scenario) use TopicSubscriber
About | Sitemap | Contact