if (!sub.matches(node, msgContext)) { sub.unmatched(node); continue;
/** * @param node * @param msgContext * @param consumers * @return true if dispatched * @throws Exception * @see org.apache.activemq.broker.region.policy.DispatchPolicy#dispatch(org.apache.activemq.broker.region.MessageReference, * org.apache.activemq.filter.MessageEvaluationContext, java.util.List) */ public boolean dispatch(MessageReference node, MessageEvaluationContext msgContext, List consumers) throws Exception { // Big synch here so that only 1 message gets dispatched at a time. // Ensures // Everyone sees the same order. synchronized (consumers) { int count = 0; for (Iterator iter = consumers.iterator(); iter.hasNext();) { Subscription sub = (Subscription)iter.next(); // Only dispatch to interested subscriptions if (!sub.matches(node, msgContext)) { sub.unmatched(node); continue; } sub.add(node); count++; } return count > 0; } }
protected List<Subscription> addSubscriptionsForDestination(ConnectionContext context, Destination dest) throws Exception { List<Subscription> rc = new ArrayList<Subscription>(); // Add all consumers that are interested in the destination. for (Iterator<Subscription> iter = subscriptions.values().iterator(); iter.hasNext();) { Subscription sub = iter.next(); if (sub.matches(dest.getActiveMQDestination())) { try { ConnectionContext originalContext = sub.getContext() != null ? sub.getContext() : context; dest.addSubscription(originalContext, sub); rc.add(sub); } catch (SecurityException e) { if (sub.isWildcard()) { LOG.debug("Subscription denied for " + sub + " to destination " + dest.getActiveMQDestination() + ": " + e.getMessage()); } else { throw e; } } } } return rc; }
public boolean canDispatch(Subscription subscription, MessageReference node) throws Exception { MessageEvaluationContext msgContext = new NonCachedMessageEvaluationContext(); msgContext.setDestination(this.destination); msgContext.setMessageReference(node); return subscription.matches(node, msgContext); } }
for (Iterator<Subscription> iter = subscriptions.values().iterator(); iter.hasNext();) { Subscription sub = iter.next(); if (sub.matches(destination) ) { throw new JMSException("Destination still has an active subscription: " + destination); if (sub.matches(destination)) { dest.removeSubscription(context, sub, 0l);
@Override public synchronized boolean recoverMessage(Message message, boolean cached) throws Exception { LOG.trace("{} recover: {}, priority: {}", this, message.getMessageId(), message.getPriority()); boolean recovered = false; MessageEvaluationContext messageEvaluationContext = new NonCachedMessageEvaluationContext(); messageEvaluationContext.setMessageReference(message); if (this.subscription.matches(message, messageEvaluationContext)) { recovered = super.recoverMessage(message, cached); if (recovered && !cached) { lastRecoveredPriority = message.getPriority(); } storeHasMessages = true; } return recovered; }
public boolean dispatch(MessageReference node, MessageEvaluationContext msgContext, List<Subscription> consumers) throws Exception { int count = 0; for (Subscription sub : consumers) { // Don't deliver to browsers if (sub.getConsumerInfo().isBrowser()) { continue; } // Only dispatch to interested subscriptions if (!sub.matches(node, msgContext)) { sub.unmatched(node); continue; } sub.add(node); count++; } return count > 0; }
/** * Respect the selectors of the subscriptions to ensure only matched messages are dispatched to * the virtual queues, hence there is no build up of unmatched messages on these destinations */ @Override protected boolean shouldDispatch(final Broker broker, Message message, Destination dest) throws IOException { //first validate that the prefix matches in the super class if (super.shouldDispatch(broker, message, dest)) { boolean matches = false; MessageEvaluationContext msgContext = new NonCachedMessageEvaluationContext(); msgContext.setDestination(dest.getActiveMQDestination()); msgContext.setMessageReference(message); List<Subscription> subs = dest.getConsumers(); for (Subscription sub : subs) { if (sub.matches(message, msgContext)) { matches = true; break; } } if (matches == false) { matches = tryMatchingCachedSubs(broker, dest, msgContext); } return matches; } return false; }
private boolean hasNoLocalConsumers(final Message message, final MessageEvaluationContext mec) { Destination regionDestination = (Destination) mec.getMessageReference().getRegionDestination(); List<Subscription> consumers = regionDestination.getConsumers(); for (Subscription sub : consumers) { if (!sub.getConsumerInfo().isNetworkSubscription() && !sub.getConsumerInfo().isBrowser()) { if (!isSelectorAware()) { LOG.trace("Not replaying [{}] for [{}] to origin due to existing local consumer: {}", new Object[]{ message.getMessageId(), message.getDestination(), sub.getConsumerInfo() }); return false; } else { try { if (sub.matches(message, mec)) { LOG.trace("Not replaying [{}] for [{}] to origin due to existing selector matching local consumer: {}", new Object[]{ message.getMessageId(), message.getDestination(), sub.getConsumerInfo() }); return false; } } catch (Exception ignored) {} } } } return true; }
protected List<Subscription> addSubscriptionsForDestination(ConnectionContext context, Destination dest) throws Exception { List<Subscription> rc = new ArrayList<Subscription>(); // Add all consumers that are interested in the destination. for (Iterator<Subscription> iter = subscriptions.values().iterator(); iter.hasNext();) { Subscription sub = iter.next(); if (sub.matches(dest.getActiveMQDestination())) { dest.addSubscription(context, sub); rc.add(sub); } } return rc; }
public boolean canDispatch(Subscription subscription, MessageReference node) throws Exception { MessageEvaluationContext msgContext = new NonCachedMessageEvaluationContext(); msgContext.setDestination(this.destination); msgContext.setMessageReference(node); return subscription.matches(node, msgContext); } }
public boolean canDispatch(Subscription subscription, MessageReference node) throws Exception { MessageEvaluationContext msgContext = new NonCachedMessageEvaluationContext(); msgContext.setDestination(this.destination); msgContext.setMessageReference(node); return subscription.matches(node, msgContext); } }
public boolean canDispatch(Subscription subscription, MessageReference node) throws Exception { MessageEvaluationContext msgContext = new NonCachedMessageEvaluationContext(); msgContext.setDestination(this.destination); msgContext.setMessageReference(node); return subscription.matches(node, msgContext); } }
public boolean canDispatch(Subscription subscription, MessageReference node) throws Exception { MessageEvaluationContext msgContext = new NonCachedMessageEvaluationContext(); msgContext.setDestination(this.destination); msgContext.setMessageReference(node); return subscription.matches(node, msgContext); } }
@Override public synchronized boolean recoverMessage(Message message, boolean cached) throws Exception { if (LOG.isTraceEnabled()) { LOG.trace("recover: " + message.getMessageId() + ", priority: " + message.getPriority()); } boolean recovered = false; MessageEvaluationContext messageEvaluationContext = new NonCachedMessageEvaluationContext(); messageEvaluationContext.setMessageReference(message); if (this.subscription.matches(message, messageEvaluationContext)) { recovered = super.recoverMessage(message, cached); if (recovered) { currentLowestPriority = Math.min(currentLowestPriority, message.getPriority()); } } return recovered; }
@Override public synchronized boolean recoverMessage(Message message, boolean cached) throws Exception { LOG.trace("{} recover: {}, priority: {}", this, message.getMessageId(), message.getPriority()); boolean recovered = false; MessageEvaluationContext messageEvaluationContext = new NonCachedMessageEvaluationContext(); messageEvaluationContext.setMessageReference(message); if (this.subscription.matches(message, messageEvaluationContext)) { recovered = super.recoverMessage(message, cached); if (recovered && !cached) { lastRecoveredPriority = message.getPriority(); } storeHasMessages = true; } return recovered; }
public boolean dispatch(MessageReference node, MessageEvaluationContext msgContext, List<Subscription> consumers) throws Exception { int count = 0; for (Subscription sub : consumers) { // Don't deliver to browsers if (sub.getConsumerInfo().isBrowser()) { continue; } // Only dispatch to interested subscriptions if (!sub.matches(node, msgContext)) { sub.unmatched(node); continue; } sub.add(node); count++; } return count > 0; }
@Override public synchronized boolean recoverMessage(Message message, boolean cached) throws Exception { LOG.trace("{} recover: {}, priority: {}", this, message.getMessageId(), message.getPriority()); boolean recovered = false; MessageEvaluationContext messageEvaluationContext = new NonCachedMessageEvaluationContext(); messageEvaluationContext.setMessageReference(message); if (this.subscription.matches(message, messageEvaluationContext)) { recovered = super.recoverMessage(message, cached); if (recovered && !cached) { lastRecoveredPriority = message.getPriority(); } storeHasMessages = true; } return recovered; }
@Override public synchronized boolean recoverMessage(Message message, boolean cached) throws Exception { LOG.trace("{} recover: {}, priority: {}", this, message.getMessageId(), message.getPriority()); boolean recovered = false; MessageEvaluationContext messageEvaluationContext = new NonCachedMessageEvaluationContext(); messageEvaluationContext.setMessageReference(message); if (this.subscription.matches(message, messageEvaluationContext)) { recovered = super.recoverMessage(message, cached); if (recovered && !cached) { lastRecoveredPriority = message.getPriority(); } storeHasMessages = true; } return recovered; }
private boolean matchesSomeConsumer(Message message, Destination dest) throws IOException { boolean matches = false; MessageEvaluationContext msgContext = new NonCachedMessageEvaluationContext(); msgContext.setDestination(dest.getActiveMQDestination()); msgContext.setMessageReference(message); List<Subscription> subs = dest.getConsumers(); for (Subscription sub: subs) { if (sub.matches(message, msgContext)) { matches = true; break; } } return matches; } }