@Override public synchronized void cancel(final MessageReference reference, final long timeBase) throws Exception { if (checkRedelivery(reference, timeBase, false)) { if (!scheduledDeliveryHandler.checkAndSchedule(reference, false)) { internalAddHead(reference); } resetAllIterators(); } else { decDelivering(reference); } }
/** * @param ref * @param message * @return */ private HandleStatus deliverStandardMessage(SimpleString dest, final MessageReference ref, Message message) { // if we failover during send then there is a chance that the // that this will throw a disconnect, we need to remove the message // from the acks so it will get resent, duplicate detection will cope // with any messages resent if (logger.isTraceEnabled()) { logger.trace("going to send message: " + message + " from " + this.getQueue()); } try { producer.send(dest, message); } catch (final ActiveMQException e) { ActiveMQServerLogger.LOGGER.bridgeUnableToSendMessage(e, ref); synchronized (refs) { // We remove this reference as we are returning busy which means the reference will never leave the Queue. // because of this we have to remove the reference here refs.remove(message.getMessageID()); // The delivering count should also be decreased as to avoid inconsistencies ((QueueImpl) ref.getQueue()).decDelivering(ref); } connectionFailed(e, false); return HandleStatus.BUSY; } return HandleStatus.HANDLED; }
@Override public void acknowledge(final MessageReference ref, final AckReason reason, final ServerConsumer consumer) throws Exception { if (nonDestructive && reason == AckReason.NORMAL) { decDelivering(ref); if (logger.isDebugEnabled()) { logger.debug("acknowledge ignored nonDestructive=true and reason=NORMAL");
decDelivering(reference);
@Override public synchronized boolean moveReference(final long messageID, final SimpleString toAddress, final Binding binding, final boolean rejectDuplicate) throws Exception { try (LinkedListIterator<MessageReference> iter = iterator()) { while (iter.hasNext()) { MessageReference ref = iter.next(); if (ref.getMessage().getMessageID() == messageID) { iter.remove(); refRemoved(ref); incDelivering(ref); try { move(null, toAddress, binding, ref, rejectDuplicate, AckReason.NORMAL, null); } catch (Exception e) { decDelivering(ref); throw e; } return true; } } return false; } }
QueueImpl queue = (QueueImpl) ref.getQueue(); queue.decDelivering(ref);