Yes. Since message acknowledgment processing is performed at the session level, message acknowledgement is still relevant after a consumer is closed. All messages consumed by the session are acknowledged for the following two examples:<br><br>// CLIENT_ACKNOWLEDGE session<br>Message msg1 = topicSubscriber1.receive();<br>Message msg2 = topicSubscriber2.receive();<br>topicSubscriber1.close();<br>msg2.acknowledge();<br><br>// transacted session<br>Message msg1 = queueReceiver.receive();<br>queueReceiver.close();<br>session.commit();<br><br><br>After the session has been closed, however, a call to the Message.acknowledge or Session.commit method throws an IllegalStateException. If close is called on a transacted session before the transaction in progress is committed, the transaction is rolled back.<br><br>Note that in order to prevent duplicate delivery of a message from a durable subscription or queue, a message that can still be acknowledged by a session cannot be redelivered to another message consumer. The message can only be redelivered to another message consumer when it can no longer be acknowledged by the session that initially received the message.
Category:JMS Interview Questions
No comments:
Post a Comment