You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by GPRSLyons <GP...@gmail.com> on 2012/03/28 00:19:51 UTC
Enrichment and Type Conversion
Gents-
As always, thanks for the help.
In my route, it is very simple for me to convert the payload to JSON...
.unmarshal().gzip()
.unmarshal().json(JsonLibrary.Jackson, MyClass.class)
However, I would like to enrich my content from multiple sources, such as...
.loop(SOURCES.length)
.enrich("source", new MyAggregationStrategy())
.end
Is there a way to apply that same conversion before the AggregationStrategy
is called? Working with byte arrays within the AggregationStrategy is
becoming very complex. I tried using the TypeConverter within the
MyAggregationStrategy, but it is challenging to determine how to replicate
the unmarshalling calls I make within the route in the same manner in the
AggregationStrategy :(
-Shan
--
View this message in context: http://camel.465427.n5.nabble.com/Enrichment-and-Type-Conversion-tp5599040p5599040.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: Enrichment and Type Conversion
Posted by Christian Müller <ch...@gmail.com>.
More complicated for me... ;-)
But it's possible...
Best,
Christian
Sent from a mobile device
Am 29.03.2012 08:36 schrieb "Raul Kripalani" <ra...@fusesource.com>:
> You can create a proxy route that consumes from a direct: endpoint,
> converts the content to a higher-level object, and lastly uses the
> recipientList DSL to send the exchange to a dynamically computed
> endpoint, extracted from a message header, e.g.
> FinalDestinationEnrich.
>
> In the original route, before calling the enrich(), simply set the
> FinalDestinationEnrich message header to the URI of the ultimate
> endpoint.
>
> How does that sound?
>
> Regards,
> Raul.
>
> On 28 Mar 2012, at 00:20, GPRSLyons <GP...@gmail.com> wrote:
>
> > Gents-
> >
> > As always, thanks for the help.
> >
> > In my route, it is very simple for me to convert the payload to JSON...
> >
> > .unmarshal().gzip()
> > .unmarshal().json(JsonLibrary.Jackson, MyClass.class)
> >
> > However, I would like to enrich my content from multiple sources, such
> as...
> >
> > .loop(SOURCES.length)
> > .enrich("source", new MyAggregationStrategy())
> > .end
> >
> > Is there a way to apply that same conversion before the
> AggregationStrategy
> > is called? Working with byte arrays within the AggregationStrategy is
> > becoming very complex. I tried using the TypeConverter within the
> > MyAggregationStrategy, but it is challenging to determine how to
> replicate
> > the unmarshalling calls I make within the route in the same manner in the
> > AggregationStrategy :(
> >
> > -Shan
> >
> > --
> > View this message in context:
> http://camel.465427.n5.nabble.com/Enrichment-and-Type-Conversion-tp5599040p5599040.html
> > Sent from the Camel - Users mailing list archive at Nabble.com.
>
Re: Enrichment and Type Conversion
Posted by Raul Kripalani <ra...@fusesource.com>.
You can create a proxy route that consumes from a direct: endpoint,
converts the content to a higher-level object, and lastly uses the
recipientList DSL to send the exchange to a dynamically computed
endpoint, extracted from a message header, e.g.
FinalDestinationEnrich.
In the original route, before calling the enrich(), simply set the
FinalDestinationEnrich message header to the URI of the ultimate
endpoint.
How does that sound?
Regards,
Raul.
On 28 Mar 2012, at 00:20, GPRSLyons <GP...@gmail.com> wrote:
> Gents-
>
> As always, thanks for the help.
>
> In my route, it is very simple for me to convert the payload to JSON...
>
> .unmarshal().gzip()
> .unmarshal().json(JsonLibrary.Jackson, MyClass.class)
>
> However, I would like to enrich my content from multiple sources, such as...
>
> .loop(SOURCES.length)
> .enrich("source", new MyAggregationStrategy())
> .end
>
> Is there a way to apply that same conversion before the AggregationStrategy
> is called? Working with byte arrays within the AggregationStrategy is
> becoming very complex. I tried using the TypeConverter within the
> MyAggregationStrategy, but it is challenging to determine how to replicate
> the unmarshalling calls I make within the route in the same manner in the
> AggregationStrategy :(
>
> -Shan
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Enrichment-and-Type-Conversion-tp5599040p5599040.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
Re: Enrichment and Type Conversion
Posted by Christian Müller <ch...@gmail.com>.
What we do in this case is:
enrich("direct:step1", firstAggregationStrategy)
enrich("direct:step2", secondAggregationStrategy)
...
from("direct:step1")
.convertBodyTo(Foo.class)
.to("cxf:...");
from("direct:step2")
.convertBodyTo(Bar.class)
.to("cxf:...");
We implemented custom type converter [1] for the converter logic. But you
can also use (custom) data formats to transform from/to the types you
need...
[1] http://camel.apache.org/type-converter.html
Best,
Christian
On Wed, Mar 28, 2012 at 12:19 AM, GPRSLyons <GP...@gmail.com> wrote:
> Gents-
>
> As always, thanks for the help.
>
> In my route, it is very simple for me to convert the payload to JSON...
>
> .unmarshal().gzip()
> .unmarshal().json(JsonLibrary.Jackson, MyClass.class)
>
> However, I would like to enrich my content from multiple sources, such
> as...
>
> .loop(SOURCES.length)
> .enrich("source", new MyAggregationStrategy())
> .end
>
> Is there a way to apply that same conversion before the AggregationStrategy
> is called? Working with byte arrays within the AggregationStrategy is
> becoming very complex. I tried using the TypeConverter within the
> MyAggregationStrategy, but it is challenging to determine how to replicate
> the unmarshalling calls I make within the route in the same manner in the
> AggregationStrategy :(
>
> -Shan
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/Enrichment-and-Type-Conversion-tp5599040p5599040.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>