camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ashwin Karpe <aska...@progress.com>
Subject Re: Question on splitter
Date Thu, 29 Apr 2010 02:59:37 GMT

Hi,

First of all, I assume that the MyObject class is serializable.

Please check out the section "Using a Pojo to do the splitting" at the link 
http://camel.apache.org/splitter.html http://camel.apache.org/splitter.html 

There is a very good and straightforward example that can do the trick for
you. 

What you need is to to take the object, split its payload, create a list of
items and allow the splitter to take it from there.

Cheers,

Ashwin... 



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


-----
--- 
Ashwin Karpe, Sr. Principal Consultant, PS - Opensource Center of Competence 
Progress Software Corporation
14 Oak Park Drive
Bedford, MA 01730
--- 
+1-972-304-9084 (Office) 
+1-972-971-1700 (Mobile) 
---- 
Blog: http://opensourceknowledge.blogspot.com/


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


Mime
View raw message