@Override protected void processDelivery(Delivery delivery) { final MessageDelivery md = (MessageDelivery) delivery.getContext(); if (delivery.remotelySettled()) { if (delivery.getTag().length > 0) { checkinTag(delivery.getTag()); } final DeliveryState state = delivery.getRemoteState(); if (state == null || state instanceof Accepted) { if (!delivery.remotelySettled()) { delivery.disposition(new Accepted()); } } else if (state instanceof Rejected) { // re-deliver /w incremented delivery counter. md.delivery = null; md.incrementDeliveryCount(); outbound.addLast(md); } else if (state instanceof Released) { // re-deliver && don't increment the counter. md.delivery = null; outbound.addLast(md); } else if (state instanceof Modified) { Modified modified = (Modified) state; if (modified.getDeliveryFailed()) { // increment delivery counter.. md.incrementDeliveryCount(); } } delivery.settle(); } md.fireWatches(); }
void setDispositionAndSettleIfRequired(IncommingMessage msg, DeliveryState state) { Delivery d = _unsettled.get(msg.getSequence()); d.disposition(state); if (d.getLink().getReceiverSettleMode() == ReceiverSettleMode.FIRST) { d.settle(); ((ReceiverImpl) d.getLink().getContext()).decrementUnsettledCount(); } }