I am pretty sure I know what the answer is but I would like to have a confirmation. When creating a JMS session for the purpose of using the session to create message producer: is there any significance of specifying what the acknowledgment mode should be? My understanding is that the message is stored by JMS provider upon exit from the publish(), send() methods and regardless of what the mode was set to be. In which case the acknowledgment mode is message consumer only concept?
Thanks for you input!
Yes the producers set the acknowledgement of the messages which is then used by the consumers and JMS server.
Message acknowledgement tells you what you consider a message successfully received and processed to be then removed from the JMS server.
In auto acknowledgement if the consumer onMessage() method completes without error the message is considered received and processed successfully, it'll be then removed from the JMS server.
In manual acknowledgement, the consumer has to make a method call to say "OK I have done successfully my work with the message". However even without technical error the consumer can choose
not to acknowledge the message because for example some business conditions were not met to process the message. In that case the onMessage() completes without error but the message says in the JMS server.
SCJP 5 , SCWCD 5, SCEA 5
Joined: May 06, 2008
I understand the differences of acknowledgment types in the consumer of the message, and the significance of the setting the acknowledgment type during creation of the consumer. I just fail to see it's significance in message producers: as far as I see it there is no impact of the acknowledgment type when creating the producer: regardless of the type of acknowledgment selected there is no need to change the code or expected different behavior. For example consumer CLIENT_ACKNOWLEDGE requires the message to be explicitly acknowledged by using ObjectMessage acknowledge() method. As far as I see it producer requires no such action: in fact the message receipt by JMS provider is guaranteed upon successful completion of the send()/publish() method.
If in fact my assumption is corrected (i.e. acknowledgment type has no impact on the message producer) then I think I would rather see have two different ways creating the session object: one for consumers who would like to control both the message acknowledgment and transaction boundaries and second one for producers whose only option is whether the is transacted or not.