users@glassfish.java.net

Re: jms bug in glassfish? (for synchronous consumption)

From: <glassfish_at_javadesktop.org>
Date: Thu, 24 Jan 2008 08:30:27 PST

"I dont want to hack ur thread.but hav one question messaging is like
fire-and-forget then why we need synchronous consumption in JMS?

Can somone clear this ?"



The JMS API defines both asynchronous (MessageListener.onMessage) and synchronous (MessageConsumer.receive) messaging; and thus both are supported. From the Java EE tutorial:

Messaging products are inherently asynchronous: There is no fundamental timing dependency between the production and the consumption of a message. However, the JMS specification uses this term in a more precise sense. Messages can be consumed in either of two ways:

Synchronously: A subscriber or a receiver explicitly fetches the message from the destination by calling the receive method. The receive method can block until a message arrives or can time out if a message does not arrive within a specified time limit.

Asynchronously: A client can register a message listener with a consumer. A message listener is similar to an event listener. Whenever a message arrives at the destination, the JMS provider delivers the message by calling the listener’s onMessage method, which acts on the contents of the message.
[Message sent by forum member 'pnguyen42' (pnguyen42)]

http://forums.java.net/jive/thread.jspa?messageID=255628