Package org.apache.activemq.filter

Examples of org.apache.activemq.filter.MessageEvaluationContext


        Message[] messages = destination.browse();
        CompositeType ct = factory.getCompositeType();
        TabularType tt = new TabularType("MessageList", "MessageList", ct, new String[] {"JMSMessageID"});
        TabularDataSupport rc = new TabularDataSupport(tt);

        MessageEvaluationContext ctx = new MessageEvaluationContext();
        ctx.setDestination(destination.getActiveMQDestination());
        BooleanExpression selectorExpression = selector == null ? null : new SelectorParser().parse(selector);

        for (int i = 0; i < messages.length; i++) {
            try {
                if (selectorExpression == null) {
                    rc.put(new CompositeDataSupport(ct, factory.getFields(messages[i])));
                } else {
                    ctx.setMessageReference(messages[i]);
                    if (selectorExpression.matches(ctx)) {
                        rc.put(new CompositeDataSupport(ct, factory.getFields(messages[i])));
                    }
                }
            } catch (Throwable e) {
View Full Code Here


    private final MessageEvaluationContext messageEvaluationContext;
    private boolean dontSendReponse;
    private boolean clientMaster = true;

    public ConnectionContext() {
      this.messageEvaluationContext = new MessageEvaluationContext();
    }
View Full Code Here

    }

    protected void assertSelector(Message message, String text, boolean expected) throws JMSException {
        BooleanExpression selector = new SelectorParser().parse(text);
        assertTrue("Created a valid selector", selector != null);
        MessageEvaluationContext context = new MessageEvaluationContext();
        context.setMessageReference((org.apache.activemq.command.Message)message);
        boolean value = selector.matches(context);
        assertEquals("Selector for: " + text, expected, value);
    }
View Full Code Here

        throw new RuntimeException("Not supported");
    }
   
       
    public synchronized boolean recoverMessage(Message message, boolean cached) throws Exception {
        MessageEvaluationContext messageEvaluationContext = new NonCachedMessageEvaluationContext();
        messageEvaluationContext.setMessageReference(message);
        if (this.subscription.matches(message, messageEvaluationContext)) {
            return super.recoverMessage(message, cached);
        }
        return false;
       
View Full Code Here

                info.setSubscribedDestination(subscription.getConsumerInfo().getDestination());
                // This destination might be a pattern
                topicStore.addSubsciption(info,subscription.getConsumerInfo().isRetroactive());
            }

            final MessageEvaluationContext msgContext = new NonCachedMessageEvaluationContext();
            msgContext.setDestination(destination);
            if (subscription.isRecoveryRequired()) {
                topicStore.recoverSubscription(clientId, subscriptionName, new MessageRecoveryListener() {
                    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);
View Full Code Here

   
    protected void dispatch(final ConnectionContext context, Message message) throws Exception {
        destinationStatistics.getMessages().increment();
        destinationStatistics.getEnqueues().increment();
        dispatchValve.increment();  
        MessageEvaluationContext msgContext = null;
        try {
            if (!subscriptionRecoveryPolicy.add(context, message)) {
                return;
            }
            synchronized (consumers) {
                if (consumers.isEmpty()) {
                    onMessageWithNoConsumers(context, message);
                    return;
                }
            }
            msgContext = context.getMessageEvaluationContext();
            msgContext.setDestination(destination);
            msgContext.setMessageReference(message);
            if (!dispatchPolicy.dispatch(message, msgContext, consumers)) {
                onMessageWithNoConsumers(context, message);
           
           
        } finally {
            dispatchValve.decrement();
            if(msgContext != null) {
                msgContext.clear();
            }
        }
    }
View Full Code Here

        return true;
    }

    public boolean addRecoveredMessage(ConnectionContext context, MessageReference message) throws Exception {
        boolean result = false;
        MessageEvaluationContext msgContext = context.getMessageEvaluationContext();
        try {
            msgContext.setDestination(message.getRegionDestination().getActiveMQDestination());
            msgContext.setMessageReference(message);
            result = matches(message, msgContext);
            if (result) {
                doAddRecoveredMessage(message);
            }

        } finally {
            msgContext.clear();
        }
        return result;
    }
View Full Code Here

    public boolean iterate() {
        synchronized(iteratingMutex) {
          RecoveryDispatch rd;
          while ((rd = getNextRecoveryDispatch()) != null) {
              try {
                  MessageEvaluationContext msgContext = new NonCachedMessageEvaluationContext();
                  msgContext.setDestination(destination);
     
                  for (QueueMessageReference node : rd.messages) {
                      if (!node.isDropped() && !node.isAcked() && (!node.isDropped() || rd.subscription.getConsumerInfo().isBrowser())) {
                          msgContext.setMessageReference(node);
                          if (rd.subscription.matches(node, msgContext)) {
                               // Log showing message dispatching
                               if (LOG.isDebugEnabled()) {
                                   LOG.debug(destination.getQualifiedName() + " - Recovery - Message pushed '" + node.hashCode() + " - " + node + "' to subscription: '" + rd.subscription + "'");
                               }
View Full Code Here

    protected MessageReferenceFilter createSelectorFilter(String selector) throws InvalidSelectorException {
        final BooleanExpression selectorExpression = new SelectorParser().parse(selector);

        return new MessageReferenceFilter() {
            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);
            }
        };
View Full Code Here

    private boolean dontSendReponse;
    private boolean clientMaster = true;
    private ConnectionState connectionState;

    public ConnectionContext() {
      this.messageEvaluationContext = new MessageEvaluationContext();
    }
View Full Code Here

TOP

Related Classes of org.apache.activemq.filter.MessageEvaluationContext

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.