@Override public void incrementDeliveryCount() { ref.incrementDeliveryCount(); }
public boolean updateDeliveryCountAfterCancel(MessageReference ref) { long lastDelSeqId = info.getLastDeliveredSequenceId(); //in activemq5, closing a durable subscription won't close the consumer //at broker. Messages will be treated as if being redelivered to //the same consumer. if (this.info.isDurable() && this.getOpenwireDestination().isTopic()) { return true; } //because delivering count is always one greater than redelivery count //we adjust it down before further calculating. ref.decrementDeliveryCount(); // This is a specific rule of the protocol if (lastDelSeqId == RemoveInfo.LAST_DELIVERED_UNKNOWN) { // this takes care of un-acked messages in non-tx deliveries // tx cases are handled by // org.apache.activemq.artemis.core.protocol.openwire.OpenWireConnection.CommandProcessor.processRollbackTransaction() ref.incrementDeliveryCount(); } else if (lastDelSeqId == RemoveInfo.LAST_DELIVERED_UNSET && !isRolledBack(ref)) { ref.incrementDeliveryCount(); } return true; }
/** * Openwire will redeliver rolled back references. * We need to return those here. */ private void returnReferences(Transaction tx, AMQSession session) throws Exception { if (session == null || session.isClosed()) { return; } RefsOperation oper = (RefsOperation) tx.getProperty(TransactionPropertyIndexes.REFS_OPERATION); if (oper != null) { List<MessageReference> ackRefs = oper.getReferencesToAcknowledge(); for (ListIterator<MessageReference> referenceIterator = ackRefs.listIterator(ackRefs.size()); referenceIterator.hasPrevious(); ) { MessageReference ref = referenceIterator.previous(); ServerConsumer consumer = null; if (ref.hasConsumerId()) { consumer = session.getCoreSession().locateConsumer(ref.getConsumerId()); } if (consumer != null) { referenceIterator.remove(); ref.incrementDeliveryCount(); consumer.backToDelivering(ref); final AMQConsumer amqConsumer = (AMQConsumer) consumer.getProtocolData(); amqConsumer.addRolledback(ref); } } } }
@Override public void rollbackRedelivery(Transaction txn, MessageReference ref, long timeBase, Map<QueueImpl, LinkedList<MessageReference>> queueMap) throws Exception { ProtonTransactionImpl tx = (ProtonTransactionImpl) txn; if (tx.getDeliveries().containsKey(ref)) { Delivery del = tx.getDeliveries().get(ref).getA(); ServerConsumer consumer = (ServerConsumer) tx.getDeliveries().get(ref).getB().getBrokerConsumer(); // Rollback normally if the delivery is not settled or a forced TX rollback is done (e.g. connection drop). if (del.remotelySettled() || !tx.isDischarged()) { super.rollbackRedelivery(tx, ref, timeBase, queueMap); } else { ref.incrementDeliveryCount(); consumer.backToDelivering(ref); del.disposition(del.getLocalState() == null ? del.getDefaultDeliveryState() : del.getLocalState()); } } else { super.rollbackRedelivery(tx, ref, timeBase, queueMap); } } }
@Override public void rollbackRedelivery(Transaction txn, MessageReference ref, long timeBase, Map<QueueImpl, LinkedList<MessageReference>> queueMap) throws Exception { ProtonTransactionImpl tx = (ProtonTransactionImpl) txn; if (tx.getDeliveries().containsKey(ref)) { Delivery del = tx.getDeliveries().get(ref).getA(); ServerConsumer consumer = (ServerConsumer) tx.getDeliveries().get(ref).getB().getBrokerConsumer(); // Rollback normally if the delivery is not settled or a forced TX rollback is done (e.g. connection drop). if (del.remotelySettled() || !tx.isDischarged()) { super.rollbackRedelivery(tx, ref, timeBase, queueMap); } else { ref.incrementDeliveryCount(); consumer.backToDelivering(ref); del.disposition(del.getLocalState() == null ? del.getDefaultDeliveryState() : del.getLocalState()); } } else { super.rollbackRedelivery(tx, ref, timeBase, queueMap); } } }