[jboss-dev-forums] [Design of Messaging on JBoss (Messaging/JBoss)] - DeliveryCount & ACKs
clebert.suconic@jboss.com
do-not-reply at jboss.com
Tue Feb 17 14:55:00 EST 2009
I have been working with https://jira.jboss.org/jira/browse/JBMESSAGING-1294, and this is the current scenario:
- The MessageReference.deliveryCount is only updated after ACKs.
Say, if you:
- received a message
- called message.acknowledge
- called rollback
When you receive that same message again, the deliveryCounter will be incremented, as the ACK will have it incremented:
| Class: ServerConsumerImpl
| {
| ...
| Method acknowledge(final boolean autoCommitAcks, final Transaction tx, final long messageID)
| {
| ...
| if (autoCommitAcks)
| {
| ref.getQueue().acknowledge(ref);
| }
| else
| {
| ref.getQueue().acknowledge(tx, ref);
|
| // Del count is not actually updated in storage unless it's
| // cancelled
| ref.incrementDeliveryCount();
| }
| }
|
If you are using AUTO_ACK (In JMS Terms that means non-transacted), that means you won't ever need to increment the DeliveryCount, as you will receive as soon as the message hit the client.
However if you are using MessageListener, that shouldn't be true. If you receive a message and an exception was thrown, the counter should be incremented also. But the ClientConsumer can't call ACK, as that would remove it from the Queue.
So, that means that Acknowledge requires a different semantic when an exception is caught on JMSMessageListenerWrapper.
One way to fix this, would be to change the ACK call signature on ClientSessionInternal:
| void acknowledge(long consumerID, long messageID) throws MessagingException; // Maybe I would leave this
|
| void acknowledge(long consumerID, long messageID, boolean autoACK) throws MessagingException;
|
And have the JMSMessageListenerWrapper doing:
| catch (RuntimeException e)
| {
| if (!transactedOrClientAck)
| {
| try
| {
|
| consumer.acknowledge(jbm.getCoreMessage(), false);
|
| session.getCoreSession().rollback();
|
| session.setRecoverCalled(true);
| }
| catch (Exception e2)
| {
| log.error("Failed to recover session", e2);
| }
| }
| }
|
With that, the AutoACK property would aways be sent on SessionAcknowledgeMessage, leaving the AutoACK to be controlled from the client.
(I could extend the packet if the boolean is considered a problem, & if this solution is acceptable).
The only problem I found on this solution, is requiring a type-cast to ClientConsumerInternal on JBossMessageConsumer.
Any thoughts?
View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4210836#4210836
Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4210836
More information about the jboss-dev-forums
mailing list