/** * A strategy hook to allow per-message caches to be cleared */ protected void clearMessageCache() { if (loaded) { messageReference.decrementReferenceCount(); } message = null; dropped = false; loaded = false; }
/** * remove the message at the cursor position */ @Override public synchronized void remove() { if (last != null) { last.decrementReferenceCount(); } iter.remove(); }
@Override public final synchronized void remove() { size--; if (iterator!=null) { iterator.remove(); } if (last != null) { last.decrementReferenceCount(); } }
/** * remove the message at the cursor position */ @Override public synchronized void remove() { iter.remove(); if (last != null) { last.decrementReferenceCount(); } }
@Override public synchronized void remove(MessageReference node) { list.remove(node); node.decrementReferenceCount(); }
@Override public synchronized List<MessageReference> remove(ConnectionContext context, Destination destination) throws Exception { List<MessageReference> rc = new ArrayList<MessageReference>(); for (Iterator<MessageReference> iterator = list.iterator(); iterator.hasNext();) { MessageReference r = iterator.next(); if (r.getRegionDestination() == destination) { r.decrementReferenceCount(); rc.add(r); iterator.remove(); } } return rc; }
/** * clear all pending messages */ @Override public synchronized void clear() { for (Iterator<MessageReference> i = list.iterator(); i.hasNext();) { MessageReference ref = i.next(); ref.decrementReferenceCount(); } list.clear(); }
private synchronized List<MessageReference> expireOldMessages() { List<MessageReference> expired = new ArrayList<MessageReference>(); if (!memoryList.isEmpty()) { for (Iterator<MessageReference> iterator = memoryList.iterator(); iterator.hasNext();) { MessageReference node = iterator.next(); if (node.isExpired()) { node.decrementReferenceCount(); expired.add(node); iterator.remove(); } } } return expired; }
public Message getMessage() throws IOException { if (!dropped && !loaded) { loaded = true; messageReference.incrementReferenceCount(); message = messageReference.getMessage(); if (message == null) { messageReference.decrementReferenceCount(); dropped = true; loaded = false; } } return message; }
protected void doBrowseList(List<Message> browseList, int max, PendingList list, ReentrantReadWriteLock lock, ConnectionContext connectionContext, String name) throws Exception { List<MessageReference> toExpire = new ArrayList<MessageReference>(); lock.readLock().lock(); try { addAll(list.values(), browseList, max, toExpire); } finally { lock.readLock().unlock(); } for (MessageReference ref : toExpire) { if (broker.isExpired(ref)) { LOG.debug("expiring from {}: {}", name, ref); messageExpired(connectionContext, ref); } else { lock.writeLock().lock(); try { list.remove(ref); } finally { lock.writeLock().unlock(); } ref.decrementReferenceCount(); } } }
@Override public synchronized void destroy() throws Exception { stop(); for (Iterator<MessageReference> i = memoryList.iterator(); i.hasNext();) { MessageReference node = i.next(); node.decrementReferenceCount(); } memoryList.clear(); destroyDiskList(); }
@Override public synchronized void gc() { for (MessageReference msg : batchList) { rollback(msg.getMessageId()); msg.decrementReferenceCount(); } batchList.clear(); clearIterator(false); batchResetNeeded = true; setCacheEnabled(false); }
/** * @param node * @see org.apache.activemq.broker.region.cursors.AbstractPendingMessageCursor#remove(org.apache.activemq.broker.region.MessageReference) */ @Override public synchronized void remove(MessageReference node) { if (memoryList.remove(node) != null) { node.decrementReferenceCount(); } if (!isDiskListEmpty()) { try { getDiskList().remove(node.getMessageId().getPlistLocator()); } catch (IOException e) { throw new RuntimeException(e); } } }
@Override public void onSuccess() { Destination regionDestination = (Destination) node.getRegionDestination(); regionDestination.getDestinationStatistics().getDispatched().increment(); regionDestination.getDestinationStatistics().getInflight().increment(); node.decrementReferenceCount(); }
@Override public void onFailure() { Destination regionDestination = (Destination) node.getRegionDestination(); regionDestination.getDestinationStatistics().getDispatched().increment(); regionDestination.getDestinationStatistics().getInflight().increment(); node.decrementReferenceCount(); } });
@Override protected void acknowledge(ConnectionContext context, MessageAck ack, MessageReference node) throws IOException { this.setTimeOfLastMessageAck(System.currentTimeMillis()); Destination regionDestination = (Destination) node.getRegionDestination(); regionDestination.acknowledge(context, this, ack, node); redeliveredMessages.remove(node.getMessageId()); node.decrementReferenceCount(); ((Destination)node.getRegionDestination()).getDestinationStatistics().getDequeues().increment(); if (info.isNetworkSubscription()) { ((Destination)node.getRegionDestination()).getDestinationStatistics().getForwards().add(ack.getMessageCount()); } }
private void discard(MessageReference message) { discarding = true; try { message.decrementReferenceCount(); matched.remove(message); discarded++; if (destination != null) { destination.getDestinationStatistics().getDequeues().increment(); } LOG.debug("{}, discarding message {}", this, message); Destination dest = (Destination) message.getRegionDestination(); if (dest != null) { dest.messageDiscarded(getContext(), this, message); } broker.getRoot().sendToDeadLetterQueue(getContext(), message, this, new Throwable("TopicSubDiscard. ID:" + info.getConsumerId())); } finally { discarding = false; } }
/** * Discard any expired messages from the matched list. Called from a * synchronized block. * * @throws IOException */ protected void removeExpiredMessages() throws IOException { try { matched.reset(); while (matched.hasNext()) { MessageReference node = matched.next(); node.decrementReferenceCount(); if (node.isExpired()) { matched.remove(); node.decrementReferenceCount(); if (broker.isExpired(node)) { ((Destination) node.getRegionDestination()).getDestinationStatistics().getExpired().increment(); broker.messageExpired(getContext(), node, this); } break; } } } finally { matched.release(); } }
@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(); } } }
private void dispatchMatched() throws IOException { synchronized (matchedListMutex) { if (!matched.isEmpty() && !isFull()) { try { matched.reset(); while (matched.hasNext() && !isFull()) { MessageReference message = matched.next(); message.decrementReferenceCount(); matched.remove(); // Message may have been sitting in the matched list a while // waiting for the consumer to ak the message. if (message.isExpired()) { discard(message); continue; // just drop it. } dispatch(message); } } finally { matched.release(); } } } }