public void DeliverAcks()
{
MessageAck ack = null;
if(this.deliveringAcks.CompareAndSet(false, true))
{
if(this.IsAutoAcknowledgeEach)
{
lock(this.dispatchedMessages)
{
ack = MakeAckForAllDeliveredMessages(AckType.DeliveredAck);
if(ack != null)
{
Tracer.Debug("Consumer - DeliverAcks clearing the Dispatch list");
this.dispatchedMessages.Clear();
}
else
{
ack = this.pendingAck;
this.pendingAck = null;
}
}
}
else if(pendingAck != null && pendingAck.AckType == (byte) AckType.ConsumedAck)
{
ack = pendingAck;
pendingAck = null;
}
if(ack != null)
{
MessageAck ackToSend = ack;
try
{
this.session.SendAck(ackToSend);
}
catch(Exception e)
{
Tracer.DebugFormat("{0} : Failed to send ack, {1}", this.info.ConsumerId, e);
}
}
else
{
this.deliveringAcks.Value = false;
}
}
}