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 : 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


        slowConsumer = val;
    }

    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

            t=0;
        // Well the buffer is really empty then.
        if(messages[t]==null)
            return;
        // Keep dispatching until t hit's tail again.
        MessageEvaluationContext msgContext=context.getMessageEvaluationContext();
        do{
            MessageReference node=messages[t];
            try{
                msgContext.setDestination(node.getRegionDestination().getActiveMQDestination());
                msgContext.setMessageReference(node);
                if(sub.matches(node,msgContext)){
                    sub.add(node);
                }
            }finally{
                msgContext.clear();
            }
            t++;
            if(t>=messages.length)
                t=0;
        }while(t!=tail);
View Full Code Here

   
    public CompositeData[] browse(String selector) throws OpenDataException, InvalidSelectorException{
        Message[] messages=destination.browse();
        ArrayList c = new ArrayList();
       
        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 ) {
                    c.add(OpenTypeSupport.convert(messages[i]));
                } else {
                    ctx.setMessageReference(messages[i]);
                    if ( selectorExpression.matches(ctx) ) {
                        c.add(OpenTypeSupport.convert(messages[i]));
                    }
                }
               
View Full Code Here

     */
    public List browseMessages(String selector) throws InvalidSelectorException {
        Message[] messages = destination.browse();
        ArrayList answer = new ArrayList();

        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 {
                Message message = messages[i];
                if (selectorExpression == null) {
                    answer.add(OpenTypeSupport.convert(message));
                }
                else {
                    ctx.setMessageReference(message);
                    if (selectorExpression.matches(ctx)) {
                        answer.add(message);
                    }
                }

View Full Code Here

        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

    }

    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

       
        // Re-dispatch the messages from the buffer.
        ArrayList copy = new ArrayList(buffer);

        if (!copy.isEmpty()) {
            MessageEvaluationContext msgContext = context.getMessageEvaluationContext();
            try {
                for (Iterator iter = copy.iterator(); iter.hasNext();) {
                    TimestampWrapper timestampWrapper = (TimestampWrapper) iter.next();
                    MessageReference message = timestampWrapper.message;
                    msgContext.setDestination(message.getRegionDestination().getActiveMQDestination());
                    msgContext.setMessageReference(message);
                    if (sub.matches(message, msgContext)) {
                        sub.add(timestampWrapper.message);
                    }
                }
            }finally {
                msgContext.clear();
            }
        }
    }
View Full Code Here

    public void recover(ConnectionContext context, Topic topic, Subscription sub) throws Exception {
        // Re-dispatch the messages from the buffer.
        List copy = buffer.getMessages(sub);
        if( !copy.isEmpty() ) {
            MessageEvaluationContext msgContext = context.getMessageEvaluationContext();
            try {
                for (Iterator iter = copy.iterator(); iter.hasNext();) {
                    MessageReference node = (MessageReference) iter.next();
                    msgContext.setDestination(node.getRegionDestination().getActiveMQDestination());
                    msgContext.setMessageReference(node);
                    if (sub.matches(node, msgContext) ) {
                        sub.add(node);
                    }
                }
            } finally {
                msgContext.clear();
            }
        }
    }
View Full Code Here

        // while
        // setting up a subscription. avoid out of order messages, duplicates
        // etc.
        dispatchValve.turnOff();

        MessageEvaluationContext msgContext = context.getMessageEvaluationContext();
        try {
            synchronized (consumers) {
                consumers.add(sub);
            }

            highestSubscriptionPriority = calcHighestSubscriptionPriority();
            msgContext.setDestination(destination);

            synchronized (messages) {
                // Add all the matching messages in the queue to the
                // subscription.
                messages.reset();
                while(messages.hasNext()) {

                    QueueMessageReference node = (QueueMessageReference) messages.next();
                    if (node.isDropped()) {
                        continue;
                    }

                    try {
                        msgContext.setMessageReference(node);
                        if (sub.matches(node, msgContext)) {
                            sub.add(node);
                        }
                    }
                    catch (IOException e) {
                        log.warn("Could not load message: " + e, e);
                    }
                }
            }

        }
        finally {
            msgContext.clear();
            dispatchValve.turnOn();
        }
    }
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.