Is there a way for a consumer in JMS to automatically send an acknowledgement message to a producer (not only to the server) to notify the reception of a message?

Jerry Smith

There is no portable, automatic mechanism for a consumer to acknowledge message receipt with the producer. Providing such a mechanism is actually quite difficult because of factors such as time-outs, etc.

The only reliable way to handle producer-consumer communications in which the producer requires acknowledgment is through an application-specific request-reply scenario.

One general strategy is for the messaging-producing client to provide "destination-based contact information" in the message header so that the message-consuming client can use this information to publish/send a reply. JMS provides general-purpose functionality for request-reply operations. See the following in the JMS API documentation: the TopicRequestor and QueueRequestor convenience classes, plus Message, in particular, the convenience methods associated with the JMSReplyTo and JMSCorrelationID message header fields.

The SonicMQ Programming Guide, available from the Progress/SonicMQ website, discusses this issue. The SonicMQ software distribution provides request-reply examples as well.