Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JMS MessageConsumer's messageListener makes push or pull?

Tags:

java

jms

What really happens under the hood when i set a messageListener on my queue MessageConsumer object. Does the MessageConsumer object make some sort of polling ehind the scene or this is a real push made by the JMS server?

Java Message Service (O'Reilly Java Series) by David A. Chappell, Richard Monson-Haefel and Mark Richards, p10 CHAPTER1: Point-to-point

The point-to-point messaging model has traditionally been a pullbased or polling-based model, where messages are requested from the queue instead of being pushed to the client automatically

http://docs.oracle.com/javaee/1.4/tutorial/doc/JMS4.html#wp79175

When message delivery begins, the JMS provider automatically calls the message listener's onMessage method whenever a message is delivered.

Thanks, Kod

like image 355
kod canavari Avatar asked Apr 11 '12 14:04

kod canavari


1 Answers

These two do not contradict each other. P2P is essentially pull-based, in that it is receiver's responsibility to read a message once it is sent by a producer. onMessage() method that you mentioned in your 2nd quote is a notification mechanism used to initiate the pull. These variations also referred to as sync vs async modes of receiving JMS messages, as for example in this chapter in Java Tutorial.

like image 50
mazaneicha Avatar answered Oct 17 '22 09:10

mazaneicha