I have a very simple question: when we speak of acknowledgement in JMS what does it actually mean?
Is it acknowledgement from the Message Receiver to the message producer? or is it acknowledgement from the message listener to the JMS container?
Acknowledgement from the listener to the container that the message is received and processed. JMS is asynchronous and so the consumer does not know who the producer is.
Googling doesn't make you a genius. But not Googling makes you dumber.
Joined: Sep 23, 2009
Thank you for the reply.
When we are producing a message,we create a queue session with an acknowledgement mode parameter. In this case is the acknowledgement from the container to the message producer?
Also if possible, can you give me a scenario when a message will not be registered with a queue . I want to test what happens when no acknowledgement is received. If it is not asking for much.
Message Acknowledgement has nothing to do with the producer. The Queue Session has Acknowledgement mode as one of it's parameters because you can create consumers/producers alike from a session and the Ack Mode affects only the consumer.
message will not be registered with a queue
Not sure what exactly you mean by that. Are you saying when will a message be *not* sent to the queue, after a producer calls send(..)? The API has the following Exceptions for the send() method:
JMSException - if the JMS provider fails to send the message due to some internal error. Internal error is anything related to your network, port accessibility, provider not running scenarios..
MessageFormatException - if an invalid message is specified.
InvalidDestinationException - if a client uses this method with an invalid destination.
UnsupportedOperationException - if a client uses this method with a MessageProducer that specified a destination at creation time.
And when a message is not acknowledged by the consumer, the JMS provider retains the message and delivers it the next time again, till an acknowledgement is received (unless, the Ack Mode is AUTO_ACKNOWLEDGE in which case, a delivery to the consumer is automatically acknowledged.
Joined: Sep 23, 2009
Thank you Prabhaharan. I was wrong in assuming that even during message production the JMS provider acknowledges receipt of a message.
Thank you for all your inputs, it cleared many of my doubts especially
The Queue Session has Acknowledgement mode as one of it's parameters because you can create consumers/producers alike from a session and the Ack Mode affects only the consumer