camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From DaHoopster <hw...@structuralinvest.com>
Subject Question on splitter
Date Thu, 29 Apr 2010 01:44:39 GMT

Hi,

I am having trouble using the splitter. I think it's a very simple problem
but I just can't figure what. I have tried a couple of way to split but no
luck. Here is what I have:

Method 1:
=====================================================================
route config:

        from("activemq:queue:inputQueue?jmsMessageType=Object").
                to("customSorter").
                split(body()).
                to("activemq:queue:outputQueue?jmsMessageType=Text");

My customerSorter code:

the object.getNumbers returns a list of MyNumber object

    public void process(Exchange exchange) throws Exception
    {
        final MyObject object = exchange.getIn().getBody(MyObject.class);
        final MyObject sorted = sort(object);
        exchange.getIn().setBody(object.getNumbers());
    }

For some reason, I am not getting anything on the output queue.


Method 2:
=====================================================================

Route config:

        from("activemq:queue:inputQueue?jmsMessageType=Object").
                to("customSorter").
                split(new MySplitExpression()).
                to("activemq:queue:outputQueue?jmsMessageType=Text");

MySplitExpression:

    public <T> T evaluate(final Exchange exchange, final Class<T> tClass)
    {
        final MyObject myObject =
exchange.getIn().copy().getBody(MyObject.class);
        final List<Message> answer = new LinkedList<Message>();
        for (final MyNumber myNumber : inventory.getNumbers())
        {
            final Message answerMessage = exchange.getIn().copy();
            answerMessage.setBody(myNumber, MyNumber.class);
            System.out.println("=== splitting ===");
        }
        return (T) answer;
    }

I am seeing the message being printed out but I still don't have any
messages on the output queue.

Could you help me see what's going on here?

Thanks,
Han
-- 
View this message in context: http://old.nabble.com/Question-on-splitter-tp28395839p28395839.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Mime
View raw message