James.Strachan wrote:
> 
> On 5/31/07, Nick Outram <[EMAIL PROTECTED]> wrote:
>>
>> I've been struggling to use the splitter component to split an incoming
>> JaxB
>> representation of an order message into its constituent transactions; the
>> message is coming from an activemq endpoint. After hours of wandering
>> through twisty little generics all alike... I think I've done my brain
>> some
>> damage and could do with an example if somebody knows if it's possible
>> any
>> takers? :)
> 
> LOL
> 
> So I guess the main thing is to write the Expression to extract the
> items from the order. Since these are Jaxb POJOs you might wanna use
> something like ruby/groovy/jxpath or something. It might be easiest to
> start off with just writing a Java Expression....
> 
> from("activemq:someQueue").splitter(new Expression<Exchange>() {
>   public Object evaluate(Exchange exchange) {
>      Order order = exchange.getIn().getBody(Order.class);
>      return order..getLineItems();
>   }
> }).to("activemq:anotherQueue");
> 
> you could wrap this expression up in a helper method if you find it
> useful in multiple rules. Once thats working, you could try a
> groovy/beanshell/ruby alternative maybe?
> 
> -- 
> James
> -------
> http://macstrac.blogspot.com/
> 
> 

I have the same problem, I want to split the content of a text file to
others messages and send then to a queue. What is the type tu return with
evaluate() method.

from("file:insert_request.sql").splitter(new Expression<Exchange>() 
{
        public Object evaluate(Exchange exchange)
        {
                return exchange.getIn().getBody(String.class).split("\n");
        }
}).to("jdbc:dataSource");

-- 
View this message in context: 
http://www.nabble.com/use-of-splitter-component-to-split-serialised-JaxB-tp10899172s22882p15183693.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Reply via email to