@Override public boolean contains(MessageReference message) { if (message != null) { return this.map.containsKey(message.getMessageId()); } return false; }
@Override public boolean contains(MessageReference message) { if (message != null) { return this.map.containsKey(message.getMessageId()); } return false; }
/** * mark this message as being received * * @param message */ public void rollback(final MessageReference message) { MessageId id = message.getMessageId(); rollback(id); }
private boolean isDuplicate(MessageReference node) { boolean duplicate = false; if (enableAudit && audit != null) { duplicate = audit.isDuplicate(node); if (LOG.isDebugEnabled()) { if (duplicate) { LOG.debug("{}, ignoring duplicate add: {}", this, node.getMessageId()); } } } return duplicate; }
/** * Check the MessageId is in order * * @param message * * @return true if the id is in order */ public boolean isInOrder(final MessageReference message) { return isInOrder(message.getMessageId()); }
/** * Checks if this message has been seen before * * @param message * @return true if the message is a duplicate */ public boolean isDuplicate(final MessageReference message) { MessageId id = message.getMessageId(); return isDuplicate(id); }
@Override public boolean evaluate(ConnectionContext context, MessageReference r) { return messageId.equals(r.getMessageId().toString()); }
protected int getPriority(MessageReference message) { int priority = javax.jms.Message.DEFAULT_PRIORITY; if (message.getMessageId() != null) { priority = Math.max(message.getMessage().getPriority(), 0); priority = Math.min(priority, 9); } return priority; }
private boolean willBeInOrder(List<MessageReference> list) { // for a single consumer inserting at head will be in order w.r.t brokerSequence but // will not be if there were multiple consumers in the mix even if this is the last // consumer to close (noConsumers==true) return !redeliveredWaitingDispatch.isEmpty() && list != null && !list.isEmpty() && redeliveredWaitingDispatch.iterator().next().getMessageId().getBrokerSequenceId() > list.get(list.size() - 1).getMessageId().getBrokerSequenceId(); } }
private void trackLastCached(MessageReference node) { if (isAsync(node.getMessage())) { pruneLastCached(); pendingCachedIds.add(node.getMessageId()); } else { setLastCachedId(SYNC_ADD, node.getMessageId()); } }
@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; }
public PendingNode removeFromMap(MessageReference message) { PendingNode removed = this.map.remove(message.getMessageId()); if (removed != null) { try { messageSize.addSize(-removed.getMessage().getSize()); } catch (Exception e) { //expected for NullMessageReference } } return removed; } }
public DispatchedNode(final MessageReference node) { super(); this.size = node.getSize(); this.messageId = node.getMessageId(); this.destination = node.getRegionDestination() instanceof Destination ? ((Destination)node.getRegionDestination()) : null; }
protected MessageAck convertToNonRangedAck(MessageAck ack, MessageReference node) { // the original ack may be a ranged ack, but we are trying to delete // a specific // message store here so we need to convert to a non ranged ack. if (ack.getMessageCount() > 0) { // Dup the ack MessageAck a = new MessageAck(); ack.copy(a); ack = a; // Convert to non-ranged. ack.setMessageCount(1); } // always use node messageId so we can access entry/data Location ack.setFirstMessageId(node.getMessageId()); ack.setLastMessageId(node.getMessageId()); return ack; }
public void addToMap(MessageReference message, PendingNode node) { PendingNode previous = this.map.put(message.getMessageId(), node); if (previous != null) { try { messageSize.addSize(-previous.getMessage().getSize()); } catch (Exception e) { //expected for NullMessageReference } } try { messageSize.addSize(message.getSize()); } catch (Exception e) { //expected for NullMessageReference } }
@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); } } }
/** * store will have a pending ack for all durables, irrespective of the * selector so we need to ack if node is un-matched */ @Override public void unmatched(MessageReference node) throws IOException { MessageAck ack = new MessageAck(); ack.setAckType(MessageAck.UNMATCHED_ACK_TYPE); ack.setMessageID(node.getMessageId()); Destination regionDestination = (Destination) node.getRegionDestination(); regionDestination.acknowledge(this.getContext(), this, ack, node); }
@Override public void acknowledge(ConnectionContext context, Subscription sub, final MessageAck ack, final MessageReference node) throws IOException { if (topicStore != null && node.isPersistent()) { DurableTopicSubscription dsub = (DurableTopicSubscription) sub; SubscriptionKey key = dsub.getSubscriptionKey(); topicStore.acknowledge(context, key.getClientId(), key.getSubscriptionName(), node.getMessageId(), convertToNonRangedAck(ack, node)); } messageConsumed(context, node); }
@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()); } }