How does JMS Receive work internally?

I am trying to answer few questions based on my experience on JMS.

Answer 1:- JMS is Java Message Service API; it provides uniform interface for Java clients to access messaging framework. Beneath JMS API is a JMS compliant messaging provider, for example WebSphere MQ provider.
JMS supports transport of a payload over any messaging protocol to destinations viz. Queue and Topic.
These are basics of JMS.

How does receive work?
JMS specification provides two important classes:- MessageConsumer and MessageListener. MessageConsumer class allows a JMS client to synchronously receive JMS messages by calling any of its receive() method. This call will be blocking thread until a message is received.
Otherwise, asynchronous receive can be made by registering an object of MessageListener with MessageConsumer.
It is JMSProvider who get to know that a message is arrived in its local destination and its job is to deliver messages to either polling message consumer thread or non-polling registered message listener thread.

Answer 2:-
MessageConsumer API has two variants of receive: receive() and receive(long timeout). The latter variant lets MessageConsumer thread block until message arrives within specific timeout period or else it times out.

Different messaging frameworks might implement blocking feature in different ways. As JMS objects are JNDI administered objects and provider specific proxy objects are returned to JMS client, it means that the client is unaware of how blocking is happening in background. A particular messaging framework may choose message consumer thread polling after a particular time period. Alternatively, it may choose to block until notification is sent.

I am not sure if you are looking answer for a particular JMS compliant messaging framework?

Answer 3:-
I guess by JMS scaling you mean ability to have many publishers/subscribers, many destinations over multiple physical machines. JMS scaling requires support of underlying messaging provider to support some sort of clustering/fail over. As such JMS specification does not support scalability. Correct me if I am wrong on this? For example I have worked on JMS compliant WebSphere MQ which provides clustering support.

Leave a Comment

bahis casinocanlı casino siteleritürkçe altyazılı pornocanlı bahis casino