public SubscriptionStatistics(boolean enabled) { consumedCount = new CountStatisticImpl("consumedCount", "The number of messages that have been consumed by the subscription"); enqueues = new CountStatisticImpl("enqueues", "The number of messages that have been sent to the subscription"); dispatched = new CountStatisticImpl("dispatched", "The number of messages that have been dispatched from the subscription"); dequeues = new CountStatisticImpl("dequeues", "The number of messages that have been acknowledged from the subscription"); inflightMessageSize = new SizeStatisticImpl("inflightMessageSize", "The size in bytes of messages dispatched but awaiting acknowledgement"); addStatistic("consumedCount", consumedCount); addStatistic("enqueues", enqueues); addStatistic("dispatched", dispatched); addStatistic("dequeues", dequeues); addStatistic("inflightMessageSize", inflightMessageSize); this.setEnabled(enabled); }
@Override public synchronized void acknowledge(final ConnectionContext context, final MessageAck ack) throws Exception { this.lastAckTime = System.currentTimeMillis(); subscriptionStatistics.getConsumedCount().increment(); }
@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(); }
@Override public int getDispatchedQueueSize() { return (int)(getSubscriptionStatistics().getDispatched().getCount() - getSubscriptionStatistics().getDequeues().getCount()); }
@Override public synchronized String toString() { return "DurableTopicSubscription-" + getSubscriptionKey() + ", id=" + info.getConsumerId() + ", active=" + isActive() + ", destinations=" + durableDestinations.size() + ", total=" + getSubscriptionStatistics().getEnqueues().getCount() + ", pending=" + getPendingQueueSize() + ", dispatched=" + getSubscriptionStatistics().getDispatched().getCount() + ", inflight=" + dispatched.size() + ", prefetchExtension=" + getPrefetchExtension(); }
getSubscriptionStatistics().getDispatched().increment(); dispatched.add(node); getSubscriptionStatistics().getInflightMessageSize().addSize(node.getSize());
@Override public long getEnqueueCounter() { return getSubscriptionStatistics().getEnqueues().getCount(); }
@Override public long getDequeueCounter() { return getSubscriptionStatistics().getDequeues().getCount(); }
@Override public long getInFlightMessageSize() { return subscriptionStatistics.getInflightMessageSize().getTotalSize(); }
@Override public long getDispatchedCounter() { return getSubscriptionStatistics().getDispatched().getCount(); }
public void reset() { if (this.isDoReset()) { super.reset(); consumedCount.reset(); enqueues.reset(); dequeues.reset(); dispatched.reset(); inflightMessageSize.reset(); } }
@Override public void resetStatistics() { if (subscription != null && subscription.getSubscriptionStatistics() != null){ subscription.getSubscriptionStatistics().reset(); } }
@Override public void processMessageDispatchNotification(MessageDispatchNotification mdn) { synchronized (matchedListMutex) { try { matched.reset(); while (matched.hasNext()) { MessageReference node = matched.next(); node.decrementReferenceCount(); if (node.getMessageId().equals(mdn.getMessageId())) { synchronized(dispatchLock) { matched.remove(); getSubscriptionStatistics().getDispatched().increment(); if (isUseTopicSubscriptionInflightStats()) { dispatched.add(new DispatchedNode(node)); getSubscriptionStatistics().getInflightMessageSize().addSize(node.getSize()); } node.decrementReferenceCount(); } break; } } } finally { matched.release(); } } }
@Override public long getEnqueueCounter() { return getSubscriptionStatistics().getEnqueues().getCount(); }
@Override public int getDispatchedQueueSize() { return (int)(getSubscriptionStatistics().getDispatched().getCount() - getSubscriptionStatistics().getDequeues().getCount()); }
@Override public synchronized String toString() { return "DurableTopicSubscription-" + getSubscriptionKey() + ", id=" + info.getConsumerId() + ", active=" + isActive() + ", destinations=" + durableDestinations.size() + ", total=" + getSubscriptionStatistics().getEnqueues().getCount() + ", pending=" + getPendingQueueSize() + ", dispatched=" + getSubscriptionStatistics().getDispatched().getCount() + ", inflight=" + dispatched.size() + ", prefetchExtension=" + getPrefetchExtension(); }
@Override public long getDequeueCounter() { return getSubscriptionStatistics().getDequeues().getCount(); }
private void addReferencesAndUpdateRedispatch(LinkedList<MessageReference> redispatch, Destination destination, List<MessageReference> dispatched) { ArrayList<MessageReference> references = new ArrayList<MessageReference>(); for (MessageReference r : dispatched) { if (r.getRegionDestination() == destination) { references.add(r); getSubscriptionStatistics().getInflightMessageSize().addSize(-r.getSize()); } } redispatch.addAll(0, references); destination.getDestinationStatistics().getInflight().subtract(references.size()); dispatched.removeAll(references); }
@Override public long getDispatchedCounter() { return getSubscriptionStatistics().getDispatched().getCount(); }
public void reset() { if (this.isDoReset()) { super.reset(); consumedCount.reset(); enqueues.reset(); dequeues.reset(); dispatched.reset(); inflightMessageSize.reset(); } }