assertAckMatchesDispatched(ack); getSubscriptionStatistics().getDequeues().increment(); ((Destination)node.getRegionDestination()).getDestinationStatistics().getInflight().decrement(); removeList.add(node); contractPrefetchExtension(1); } else { registerRemoveSync(context, node); acknowledge(context, ack, node); if (ack.getLastMessageId().equals(messageId)) { destination = (Destination) node.getRegionDestination(); getSubscriptionStatistics().getInflightMessageSize().addSize(-node.getSize()); getSubscriptionStatistics().getDequeues().increment(); ((Destination)node.getRegionDestination()).getDestinationStatistics().getInflight().decrement(); dispatched.remove(node); getSubscriptionStatistics().getInflightMessageSize().addSize(-node.getSize()); contractPrefetchExtension(1); } else { registerRemoveSync(context, node); expandPrefetchExtension(1); acknowledge(context, ack, node); destination = (Destination) node.getRegionDestination(); callDispatchMatched = true; Destination nodeDest = (Destination) node.getRegionDestination();
if (getPrefetchSize() == 0) { prefetchExtension.set(pull.getQuantity()); final long dispatchCounterBeforePull = getSubscriptionStatistics().getDispatched().getCount(); dest.iterate(); dispatchPending(); if (dispatchCounterBeforePull == getSubscriptionStatistics().getDispatched().getCount() || pull.isAlwaysSignalDone()) { add(QueueMessageReference.NULL_MESSAGE); dispatchPending();
int numberToDispatch = countBeforeFull(); if (numberToDispatch > 0) { setSlowConsumer(false); setPendingBatchSize(pending, numberToDispatch); int count = 0; pending.reset(); while (count < numberToDispatch && !isFull() && pending.hasNext()) { MessageReference node = pending.next(); if (node == null) { if (!isDropped(node) && canDispatch(node)) { if (!isBrowser()) { node.decrementReferenceCount(); continue; dispatch(node); count++; } else if (!pending.isEmpty() && !isSlowConsumer()) { setSlowConsumer(true); slowConsumerTargets = destinations;
/** * Occurs when a pull times out. If nothing has been dispatched since the * timeout was setup, then send the NULL message. */ final void pullTimeout(long dispatchCounterBeforePull, boolean alwaysSignalDone) { synchronized (pendingLock) { if (dispatchCounterBeforePull == getSubscriptionStatistics().getDispatched().getCount() || alwaysSignalDone) { try { prefetchExtension.set(1); add(QueueMessageReference.NULL_MESSAGE); dispatchPending(); } catch (Exception e) { context.getConnection().serviceException(e); } finally { prefetchExtension.set(0); } } } }
@Override public void add(MessageReference node) throws Exception { synchronized (pendingLock) { // The destination may have just been removed... if (!destinations.contains(node.getRegionDestination()) && node != QueueMessageReference.NULL_MESSAGE) { // perhaps we should inform the caller that we are no longer valid to dispatch to? return; } // Don't increment for the pullTimeout control message. if (!node.equals(QueueMessageReference.NULL_MESSAGE)) { getSubscriptionStatistics().getEnqueues().increment(); } pending.addMessageLast(node); } dispatchPending(); }
@Override public void afterCommit() throws Exception { Destination nodeDest = (Destination) node.getRegionDestination(); synchronized (dispatchLock) { getSubscriptionStatistics().getDequeues().increment(); if (dispatched.remove(node)) { // if consumer is removed, dispatched will be empty and inflight will // already have been adjusted getSubscriptionStatistics().getInflightMessageSize().addSize(-node.getSize()); nodeDest.getDestinationStatistics().getInflight().decrement(); } } contractPrefetchExtension(1); nodeDest.wakeup(); dispatchPending(); }
MessageDispatch md = createMessageDispatch(node, message); if (node != QueueMessageReference.NULL_MESSAGE) { getSubscriptionStatistics().getDispatched().increment(); dispatched.add(node); getSubscriptionStatistics().getInflightMessageSize().addSize(node.getSize()); if (getPrefetchSize() == 0) { while (true) { int currentExtension = prefetchExtension.get(); } else { context.getConnection().dispatchSync(md); onDispatch(node, message);
if (!isSlave()) { if (!okForAckAsDispatchDone.await(0l, TimeUnit.MILLISECONDS)) { assertAckMatchesDispatched(ack); acknowledge(context, ack, node); if (ack.getLastMessageId().equals(messageId)) { if (getPrefetchSize() == 0) { prefetchExtension = Math.max(0, prefetchExtension - index); } else if (usePrefetchExtension && context.isInTransaction()) { node.getRegionDestination().getDestinationStatistics().getInflight().decrement(); destination = node.getRegionDestination(); acknowledge(context, ack, node); dispatched.remove(node); prefetchExtension = Math.max(0, prefetchExtension - 1); sendToDLQ(context, node); node.getRegionDestination().getDestinationStatistics() .getInflight().decrement(); dequeueCounter++; index++; acknowledge(context, ack, node); if (ack.getLastMessageId().equals(messageId)) { prefetchExtension = Math.max(0, prefetchExtension dispatchPending();
@Override public void processMessageDispatchNotification(MessageDispatchNotification mdn) throws Exception { synchronized(pendingLock) { try { pending.reset(); while (pending.hasNext()) { MessageReference node = pending.next(); node.decrementReferenceCount(); if (node.getMessageId().equals(mdn.getMessageId())) { // Synchronize between dispatched list and removal of messages from pending list // related to remove subscription action synchronized(dispatchLock) { pending.remove(); createMessageDispatch(node, node.getMessage()); dispatched.add(node); getSubscriptionStatistics().getInflightMessageSize().addSize(node.getSize()); onDispatch(node, node.getMessage()); } return; } } } finally { pending.release(); } } throw new JMSException( "Slave broker out of sync with master: Dispatched message (" + mdn.getMessageId() + ") was not in the pending list for " + mdn.getConsumerId() + " on " + mdn.getDestination().getPhysicalName()); }
@Override public void setPrefetchSize(int prefetchSize) { this.info.setPrefetchSize(prefetchSize); try { this.dispatchPending(); } catch (Exception e) { LOG.trace("Caught exception during dispatch after prefetch change.", e); } } }
if (getPrefetchSize() == 0 && !isSlave()) { final long dispatchCounterBeforePull; synchronized(this) { dest.iterate(); dispatchPending(); add(QueueMessageReference.NULL_MESSAGE); dispatchPending();
/** * Occurs when a pull times out. If nothing has been dispatched since the * timeout was setup, then send the NULL message. */ final void pullTimeout(long dispatchCounterBeforePull) { synchronized (pendingLock) { if (dispatchCounterBeforePull == dispatchCounter) { try { add(QueueMessageReference.NULL_MESSAGE); dispatchPending(); } catch (Exception e) { context.getConnection().serviceException(e); } } } }
@Override public void add(MessageReference node) throws Exception { if (!active.get() && !keepDurableSubsActive) { return; } super.add(node); }
if (!isSlave()) { MessageDispatch md = createMessageDispatch(node, message); } else { context.getConnection().dispatchSync(md); onDispatch(node, message);
@Override protected MessageDispatch createMessageDispatch(MessageReference node, Message message) { MessageDispatch md = super.createMessageDispatch(node, message); if (node != QueueMessageReference.NULL_MESSAGE) { node.incrementReferenceCount(); Integer count = redeliveredMessages.get(node.getMessageId()); if (count != null) { md.setRedeliveryCounter(count.intValue()); } } return md; }
@Override public int getPendingQueueSize() { if (active.get() || keepDurableSubsActive) { return super.getPendingQueueSize(); } // TODO: need to get from store return 0; }
public void setPending(PendingMessageCursor pending) { this.pending = pending; if (this.pending!=null) { this.pending.setSystemUsage(usageManager); this.pending.setMemoryUsageHighWaterMark(getCursorMemoryHighWaterMark()); } }
public void processMessageDispatchNotification(MessageDispatchNotification mdn) throws Exception { synchronized(pendingLock) { try { pending.reset(); while (pending.hasNext()) { MessageReference node = pending.next(); node.decrementReferenceCount(); if (node.getMessageId().equals(mdn.getMessageId())) { // Synchronize between dispatched list and removal of messages from pending list // related to remove subscription action synchronized(dispatchLock) { pending.remove(); createMessageDispatch(node, node.getMessage()); dispatched.add(node); onDispatch(node, node.getMessage()); } return; } } } finally { pending.release(); } } throw new JMSException( "Slave broker out of sync with master: Dispatched message (" + mdn.getMessageId() + ") was not in the pending list for " + mdn.getConsumerId() + " on " + mdn.getDestination().getPhysicalName()); }
MessageDispatch md = createMessageDispatch(node, message); if (node != QueueMessageReference.NULL_MESSAGE) { getSubscriptionStatistics().getDispatched().increment(); dispatched.add(node); getSubscriptionStatistics().getInflightMessageSize().addSize(node.getSize()); if (getPrefetchSize() == 0) { while (true) { int currentExtension = prefetchExtension.get(); } else { context.getConnection().dispatchSync(md); onDispatch(node, message);
/** * Occurs when a pull times out. If nothing has been dispatched since the * timeout was setup, then send the NULL message. */ final void pullTimeout(long dispatchCounterBeforePull, boolean alwaysSignalDone) { synchronized (pendingLock) { if (dispatchCounterBeforePull == getSubscriptionStatistics().getDispatched().getCount() || alwaysSignalDone) { try { prefetchExtension.set(1); add(QueueMessageReference.NULL_MESSAGE); dispatchPending(); } catch (Exception e) { context.getConnection().serviceException(e); } finally { prefetchExtension.set(0); } } } }