camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mark Doyle <markjohndo...@gmail.com>
Subject Re: Splitting a POJO message into multiple messages containing values of a collection from a stored as a field on the POJO.
Date Mon, 08 Oct 2012 12:28:49 GMT
Hi Claus,

Nothing so complex actually. I simply want to call a method on the POJO's
map field.

Here's the full example:

I have a POJO arriving in a message body. The POJO has a Map field, let's
say someMap. I want to split the message into multiple messages, one for
each value in the map. I don't care about the keys.

Something like this (pseudo)
<split>
   ${body}.someMap.values()
</split>

I created a simple utility/helper class that takes the POJO and returns the
List of values which I can route through using camel:method. e.g:
<camel:split>
    <camel:method ref="myClassExtractor" method="extractValues"/>
    <to uri="seda:parametersOut"/>
</camel:split>

But I wondered if there was a one-step method, completely in configuration.

On 8 October 2012 10:00, Claus Ibsen <claus.ibsen@gmail.com> wrote:

> On Sun, Oct 7, 2012 at 5:09 PM, Mark Doyle <markjohndoyle@gmail.com>
> wrote:
> > Hi all,
> >
> > I there a simple way of taking a POJO from a message body and calling a
> > method on one of it's fields, e.g someMap.values() to return messages for
> > each element in a collection. I want to do this for a splitter.
> >
> > I can do it with various other methods, beans, processors, transformers
> etc
> > but it all seems a bit long winded.
>
> You want to invoke a method on each value from a map? And should you
> do something with their responses (eg if they are not void methods)?
>
> You can use an dynamic language like groovy, it should have extensions
> to collections to do this.
> http://camel.apache.org/groovy.html
>
>
> --
> Claus Ibsen
> -----------------
> Red Hat, Inc.
> FuseSource is now part of Red Hat
> Email: cibsen@redhat.com
> Web: http://fusesource.com
> Twitter: davsclaus
> Blog: http://davsclaus.com
> Author of Camel in Action: http://www.manning.com/ibsen
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message