Hi All,
I've the following problem unsolved regarding the filtered messages
depending on some info extractect from another queue.

The case is the following:

1. Primary queue contains the messages received from netty:tcp server
2.Depending the ID found in the body you have to select from another queue
only the messages affected to the previous ID, leaving the other messages in
the queue.
3. The returning message will be the message (if found) on the second queue,
otherwise all remains unchanged.

I've solved only partially the problem using the following camelcontext.xml:

        <route>
        <from uri="netty:tcp://localhost:5000?textline=true&amp;sync=true"/>
        <to uri="jms:MyQueue"/>
            <pollEnrich uri="jms:toTelelinkQ" strategyRef="myBeanId"/>
        </route>  -->

        <bean id="myBeanId" class="org.apache.camel.example.MyBeanProcessor"/>

due to the process myBeanId that is unable to leave the messages in the
original queue (see the following code), but all messages must be consumed
to know the body content:

// MyBeanProcessor.java

package org.apache.camel.example;

import java.io.*;

import org.apache.camel.Exchange;
import org.apache.camel.processor.aggregate.AggregationStrategy;

public class MyBeanProcessor implements AggregationStrategy {

        public Exchange aggregate(Exchange oldExchange, Exchange newExchange) {

                if (newExchange == null) {
                        // no messages in queue
                        return newExchange;
                }
                String payloadOld = oldExchange.getIn().getBody(String.class);
                String payloadNew = newExchange.getIn().getBody(String.class);

                String telelink = payloadOld.substring(5, 14);

                if (payloadNew.contains("#") & payloadNew.contains(telelink)) {
                        System.out.println("OK " + telelink + "=" + payloadNew);
                        oldExchange.getIn().setBody(payloadNew.substring(10));
                } else {
                        System.out.println("NO OK " + telelink + "<>" + 
payloadNew);
                        oldExchange.getIn().setBody(null);

                }
                return oldExchange;
        }
}

Many thanks for your help,
Romualdo
 
-- 
View this message in context: 
http://camel.465427.n5.nabble.com/Messages-queue-filtered-depending-on-info-received-by-another-queue-tp2805911p2805911.html
Sent from the Camel Development mailing list archive at Nabble.com.

Reply via email to