There are several things we need to consider while designing application involving JMS. I am involved in designing an application utilizing JMS therefore I made a check list of items needed to be considered.
1) Asynchronous versus Synchronous
Using Asynchronous or Synchronous JMS will be one of the most important factors that will influence the application design.
JMS Application Client (JMS consumer) can receive synchronous JMS message for Queue or Topic with the receive method of QueueReceiver or TopicReceiver respectively. If a message is available, the JMS implementation will return it; otherwise, the client’s call waits indefinitely for a message. The receive method has three variants
1) receive—Receive the next message for this consumer
2) receive(long timeout)—Receive the next message that arrives within the timeout interval
3) receiveNoWait—Receive the next message if one is immediately available else returns null
Please note that the thread using receive () method will have to wait until the next message is arrived.
JMS Application client (JMS consumer) can also receive messages asynchronously. The client does not need to wait; whenever a new message is arrived the client listener onMessage method is called. Read full story »