camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Willem Jiang <willem.ji...@gmail.com>
Subject Re: Question on splitter
Date Thu, 29 Apr 2010 04:57:40 GMT
Hi,

Please check out my comments in the mail.

DaHoopster wrote:
> 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.

I don't think camel know how to split the getNumbers of object.

> 
> 
> 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 ===");

You didn't put the message into the answer list.

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

Willem

Mime
View raw message