Refine search
destinationStatistics.getMessageSize().addSize(message.getSize()); MessageEvaluationContext msgContext = null; if (isReduceMemoryFootprint() && message.isMarshalled()) { message.clearUnMarshalledState(); msgContext = context.getMessageEvaluationContext(); msgContext.setDestination(destination); msgContext.setMessageReference(message); if (!dispatchPolicy.dispatch(message, msgContext, consumers)) { onMessageWithNoConsumers(context, message); dispatchLock.readLock().unlock(); if (msgContext != null) { msgContext.clear();
public void setMessageReference(MessageReference messageReference) { if (this.messageReference != messageReference) { clearMessageCache(); } this.messageReference = messageReference; }
@Override protected boolean matchesForwardingFilter(Message message, final MessageEvaluationContext mec) { boolean match = true; if (mec.getDestination().isQueue() && contains(message.getBrokerPath(), networkBrokerId)) { // potential replay back to origin match = allowReplayWhenNoConsumers && hasNoLocalConsumers(message, mec) && hasNotJustArrived(message); if (match) { LOG.trace("Replaying [{}] for [{}] back to origin in the absence of a local consumer", message.getMessageId(), message.getDestination()); } else { LOG.trace("Suppressing replay of [{}] for [{}] back to origin {}", new Object[]{ message.getMessageId(), message.getDestination(), Arrays.asList(message.getBrokerPath())} ); } } else { // use existing filter logic for topics and non replays match = super.matchesForwardingFilter(message, mec); } if (match && rateLimitExceeded()) { LOG.trace("Throttled network consumer rejecting [{}] for [{}] {}>{}/{}", new Object[]{ message.getMessageId(), message.getDestination(), matchCount, rateLimit, rateDuration }); match = false; } return match; }
@Override public boolean evaluate(ConnectionContext context, MessageReference r) throws JMSException { MessageEvaluationContext messageEvaluationContext = context.getMessageEvaluationContext(); messageEvaluationContext.setMessageReference(r); if (messageEvaluationContext.getDestination() == null) { messageEvaluationContext.setDestination(getActiveMQDestination()); } return selectorExpression.matches(messageEvaluationContext); } };
public Object evaluate(MessageEvaluationContext message) throws JMSException { try { if (message.isDropped()) { return null; } return evaluator.evaluate(message.getMessage()) ? Boolean.TRUE : Boolean.FALSE; } catch (IOException e) { throw JMSExceptionSupport.create(e); } }
public boolean matches(MessageEvaluationContext message) throws JMSException { try { if (message.isDropped()) { return false; } String messageConnectionId = message.getMessage().getProducerId().getConnectionId(); return !connectionId.equals(messageConnectionId); } catch (IOException e) { throw JMSExceptionSupport.create(e); } }
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; }
public ConnectionContext createConnectionContext() { ConnectionContext answer = new ConnectionContext(); answer.setBroker(this.broker); answer.getMessageEvaluationContext().setDestination(getActiveMQDestination()); answer.setSecurityContext(SecurityContext.BROKER_SECURITY_CONTEXT); return answer; }
@Override public boolean addRecoveredMessage(ConnectionContext context, MessageReference message) throws Exception { boolean result = false; MessageEvaluationContext msgContext = context.getMessageEvaluationContext(); try { Destination regionDestination = (Destination) message.getRegionDestination(); msgContext.setDestination(regionDestination.getActiveMQDestination()); msgContext.setMessageReference(message); result = matches(message, msgContext); if (result) { doAddRecoveredMessage(message); } } finally { msgContext.clear(); } return result; }
/** * 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; }
public boolean matches(MessageEvaluationContext message) throws JMSException { try { if (message.isDropped()) { return false; } return matches(message.getMessage().getDestination()); } catch (IOException e) { throw JMSExceptionSupport.create(e); } }
/** * Browses the current destination with the given selector returning a list * of messages */ public List<Object> browseMessages(String selector) throws InvalidSelectorException { Message[] messages = destination.browse(); ArrayList<Object> answer = new ArrayList<Object>(); MessageEvaluationContext ctx = new MessageEvaluationContext(); ctx.setDestination(destination.getActiveMQDestination()); BooleanExpression selectorExpression = selector == null ? null : SelectorParser.parse(selector); for (int i = 0; i < messages.length; i++) { try { Message message = messages[i]; if (selectorExpression == null) { answer.add(OpenTypeSupport.convert(message)); } else { ctx.setMessageReference(message); if (selectorExpression.matches(ctx)) { answer.add(message); } } } catch (Throwable e) { LOG.warn("exception browsing destination", e); } } return answer; }
@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 Object evaluate(MessageEvaluationContext message) throws JMSException { try { if (message.isDropped()) { return null; } if (jmsPropertyExpression != null) { return jmsPropertyExpression.evaluate(message.getMessage()); } try { return message.getMessage().getProperty(name); } catch (IOException ioe) { throw JMSExceptionSupport.create("Could not get property: " + name + " reason: " + ioe.getMessage(), ioe); } } catch (IOException e) { throw JMSExceptionSupport.create(e); } }
if (messageContext == null) { messageContext = new NonCachedMessageEvaluationContext(); messageContext.setMessageReference(message); messageContext.setDestination(filteredDestination.getDestination()); if (filteredDestination.matches(messageContext)) { destination = filteredDestination.getDestination(); final BrokerService brokerService = context.getConnectionContext().getBroker().getBrokerService(); for (final ActiveMQDestination destination : matchingDestinations) { if (concurrent.getCount() > 0) {
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 accept(Message message) { try { MessageEvaluationContext context = new MessageEvaluationContext(); MessageAdapter ma = new MessageAdapter(message); context.setMessageReference(ma); return expression.matches(context); } catch (Exception e) { throw new RuntimeException("ActiveMQ selector accept error " + message, e); } }
@Override public boolean recoverMessage(Message message) throws Exception { message.setRegionDestination(Topic.this); try { msgContext.setMessageReference(message); if (subscription.matches(message, msgContext)) { subscription.add(message); } } catch (IOException e) { LOG.error("Failed to recover this message {}", message, e); } return true; }
public boolean recoverMessage(Message message) throws Exception { if (selectorExpression != null) { MessageEvaluationContext ctx = new MessageEvaluationContext(); ctx.setMessageReference(store.getMessage(message.getMessageId())); if (selectorExpression.matches(ctx)) { count++; } } else { count++; } return true; }
public boolean matches(MessageEvaluationContext message) throws JMSException { try { if (message.isDropped()) { return false; } return !connectionId.equals(message.getMessage().getMessageId().getProducerId().getConnectionId()); } catch (IOException e) { throw JMSExceptionSupport.create(e); } }