I read this question(Multithreaded JMS code : CLIENT_ACKNOWLEDGE or transacted session) but I didn’t understand What is the difference between these two methods in message consumer:
- the connection is not transacted. the session is in
CLIENT_ACKNOWLEDGEmode. We receive multiple messages, then oneacknowledge(). - the connection is transacted(not
xa). the session is inAUTO_ACKNOWLEDGEmode. we receive multiple messages, then do acommit().
Is this depends on message provider behavior?
I think there is not much difference when messages are being received from just one destination. One can either use a CLIENT_ACKNOWLEDGE or Transacted session.
However when using multiple destinations in a session, say receiving message from a queue, then processing it and publishing the process result to another topic in the same session, a transacted session is more suited. So receiving and publishing message will all happen in one transaction. Based on the outcome of the message processing, transaction can either be committed or rolled back.