You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Deepthi <de...@gmail.com> on 2012/06/19 23:44:57 UTC
How to achieve both xpath and aggregator
Hi,
I have the following xml:
<orders>
<order>
<id>1</id>
<date>XXX</date>
</order>
<order>
<id>2</id>
<date>XXX</date>
</order>
<order>
<id>1</id>
<date>XXX</date>
</order>
</orders>
I want to split the above xml to multiple xml's (based on order tag) and
group the xml's which have same order id.
So my out put should look like:
XML 1:
<orders>
<order>
<id>1</id>
<date>XXX</date>
</order>
<order>
<id>1</id>
<date>XXX</date>
</order>
</orders>
XML 2:
<orders>
<order>
<id>2</id>
<date>XXX</date>
</order>
</orders>
How can i achieve this?
Thanks,
Deepthi
--
View this message in context: http://camel.465427.n5.nabble.com/How-to-achieve-both-xpath-and-aggregator-tp5714691.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: How to achieve both xpath and aggregator
Posted by Claus Ibsen <cl...@gmail.com>.
Hi
Whats the exception, and make sure the xpath expression is valid, and works.
xpath can be a pain to get working so take extra case when using that.
On Thu, Jun 28, 2012 at 5:04 PM, Deepthi <de...@gmail.com> wrote:
> Hi Claus,
>
> I still get the same exception.
>
> Thanks,
> Deepthi
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/How-to-achieve-both-xpath-and-aggregator-tp5714691p5715229.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
--
Claus Ibsen
-----------------
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus, fusenews
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen
Re: How to achieve both xpath and aggregator
Posted by Deepthi <de...@gmail.com>.
Hi Claus,
I still get the same exception.
Thanks,
Deepthi
--
View this message in context: http://camel.465427.n5.nabble.com/How-to-achieve-both-xpath-and-aggregator-tp5714691p5715229.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: How to achieve both xpath and aggregator
Posted by Claus Ibsen <cl...@gmail.com>.
On Thu, Jun 28, 2012 at 12:39 AM, Deepthi <de...@gmail.com> wrote:
> Hi Claus,
>
> I have changed it as suggested by you:
> <camel:route>
> <camel:from uri="direct:start"/>
> <camel:aggregate strategyRef="aggregatorStrategy" completionSize="2"
> completionTimeout="5000">
> <camel:correlationExpression>
> <camel:xpath>/orders/order/@id</camel:xpath>
> </camel:correlationExpression>
> <camel:bean ref="testClass" method="testMeth"/>
> <camel:to uri="file://C:/test"/>
> </camel:aggregate>
> </camel:route>
>
> It says invalid correlation key for all the input files. I can set
> ignoreInvalidCorrelationKeys to true but it just skips all the files. Where
> am I going wrong as I see the same example in camel in action as well.
>
Can you try with
<camel:xpath
resultType="java.lang.String">/orders/order/@id</camel:xpath>
To force the xpath to be a string type
> --
> View this message in context: http://camel.465427.n5.nabble.com/How-to-achieve-both-xpath-and-aggregator-tp5714691p5715196.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
--
Claus Ibsen
-----------------
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus, fusenews
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen
Re: How to achieve both xpath and aggregator
Posted by Deepthi <de...@gmail.com>.
Hi Claus,
I have changed it as suggested by you:
<camel:route>
<camel:from uri="direct:start"/>
<camel:aggregate strategyRef="aggregatorStrategy" completionSize="2"
completionTimeout="5000">
<camel:correlationExpression>
<camel:xpath>/orders/order/@id</camel:xpath>
</camel:correlationExpression>
<camel:bean ref="testClass" method="testMeth"/>
<camel:to uri="file://C:/test"/>
</camel:aggregate>
</camel:route>
It says invalid correlation key for all the input files. I can set
ignoreInvalidCorrelationKeys to true but it just skips all the files. Where
am I going wrong as I see the same example in camel in action as well.
--
View this message in context: http://camel.465427.n5.nabble.com/How-to-achieve-both-xpath-and-aggregator-tp5714691p5715196.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: How to achieve both xpath and aggregator
Posted by Claus Ibsen <cl...@gmail.com>.
On Fri, Jun 22, 2012 at 10:41 PM, Deepthi <de...@gmail.com> wrote:
> Hi,
>
> I am trying to aggregate in the following manner:
>
> <camel:route>
> <camel:from uri="direct:start"/>
> <camel:aggregate strategyRef="aggregatorStrategy">
> <camel:correlationExpression>
> <camel:xpath>/order/id</camel:xpath>
> </camel:correlationExpression>
> </camel:aggregate>
> <camel:bean ref="testClass" method="testMeth"/>
> <camel:to uri="file://C:/test"/>
> </camel:route>
>
> I am using camel 2.8.0.
> The above route throws me an exception "Definition has no children on
> Aggregate".
>
> Where am I going wrong? Any help is appreciated.
>
You need to put these inside the aggregate tag.
<camel:bean ref="testClass" method="testMeth"/>
<camel:to uri="file://C:/test"/>
That means when the message is being sent out of the aggregator its
routed to the bean and file.
> Thanks,
> Deepthi
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/How-to-achieve-both-xpath-and-aggregator-tp5714691p5714941.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
--
Claus Ibsen
-----------------
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus, fusenews
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen
Re: How to achieve both xpath and aggregator
Posted by Christian Müller <ch...@gmail.com>.
Have a look at [1]. You have to define when Camel should complete the
aggregation (e.g. after 10 messages arrived, after 10 minutes, after ...).
[1] http://camel.apache.org/aggregator2.html
Best,
Christian
On Fri, Jun 22, 2012 at 10:41 PM, Deepthi <de...@gmail.com> wrote:
> Hi,
>
> I am trying to aggregate in the following manner:
>
> <camel:route>
> <camel:from uri="direct:start"/>
> <camel:aggregate strategyRef="aggregatorStrategy">
> <camel:correlationExpression>
> <camel:xpath>/order/id</camel:xpath>
> </camel:correlationExpression>
> </camel:aggregate>
> <camel:bean ref="testClass" method="testMeth"/>
> <camel:to uri="file://C:/test"/>
> </camel:route>
>
> I am using camel 2.8.0.
> The above route throws me an exception "Definition has no children on
> Aggregate".
>
> Where am I going wrong? Any help is appreciated.
>
> Thanks,
> Deepthi
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/How-to-achieve-both-xpath-and-aggregator-tp5714691p5714941.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
Re: How to achieve both xpath and aggregator
Posted by Deepthi <de...@gmail.com>.
Hi,
I am trying to aggregate in the following manner:
<camel:route>
<camel:from uri="direct:start"/>
<camel:aggregate strategyRef="aggregatorStrategy">
<camel:correlationExpression>
<camel:xpath>/order/id</camel:xpath>
</camel:correlationExpression>
</camel:aggregate>
<camel:bean ref="testClass" method="testMeth"/>
<camel:to uri="file://C:/test"/>
</camel:route>
I am using camel 2.8.0.
The above route throws me an exception "Definition has no children on
Aggregate".
Where am I going wrong? Any help is appreciated.
Thanks,
Deepthi
--
View this message in context: http://camel.465427.n5.nabble.com/How-to-achieve-both-xpath-and-aggregator-tp5714691p5714941.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: How to achieve both xpath and aggregator
Posted by Claus Ibsen <cl...@gmail.com>.
Hi
I suggest to study the EIP patterns
http://camel.apache.org/eip
On Tue, Jun 19, 2012 at 11:44 PM, Deepthi <de...@gmail.com> wrote:
> Hi,
>
> I have the following xml:
> <orders>
> <order>
> <id>1</id>
> <date>XXX</date>
> </order>
> <order>
> <id>2</id>
> <date>XXX</date>
> </order>
> <order>
> <id>1</id>
> <date>XXX</date>
> </order>
> </orders>
>
> I want to split the above xml to multiple xml's (based on order tag) and
> group the xml's which have same order id.
>
> So my out put should look like:
>
> XML 1:
> <orders>
> <order>
> <id>1</id>
> <date>XXX</date>
> </order>
> <order>
> <id>1</id>
> <date>XXX</date>
> </order>
> </orders>
>
> XML 2:
> <orders>
> <order>
> <id>2</id>
> <date>XXX</date>
> </order>
> </orders>
>
> How can i achieve this?
>
> Thanks,
> Deepthi
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/How-to-achieve-both-xpath-and-aggregator-tp5714691.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
--
Claus Ibsen
-----------------
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus, fusenews
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen