You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by vasukfuse <va...@gmail.com> on 2012/08/14 09:47:04 UTC

problem in aggregation

Hi All

i have to aggregate two XML files which are available at different 
times.but i am getting error in out put file.

here i am providing my code error details

 public void configure() {
				  try {
				            DataFormat bindy = new
BindyCsvDataFormat("com.softedge.dto");
				            DataFormat bindy1 = new
BindyCsvDataFormat("com.softedge.dto");
				                  from("file://TEST?fileName=order.csv&noop=true").
				                  unmarshal(bindy).
				                  marshal().
				                  xstream().
				                  to("file://TESTOUT?fileName=order.xml");
				                  from("file://TEST?fileName=order_line.csv&noop=true").
				                  unmarshal(bindy1).
				                  marshal().
				                  xstream().
				                  to("file://TESTOUT?fileName=orderLine.xml");
				                  Thread.sleep(1000);
				                  from("file://TESTOUT?idempotent=true")
				                  .aggregate(body(),new MyAggregationStrategy())
				                      .completionTimeout(30000)
				                     // .batchSize(2)
				                  .to("file://TESTOUTA?fileName=aggregate.xml");
				                 



the out put file should contain the data from Order.xml, OrderLine.xml 

but the output file aggregate.xml  contains only orderline out put and it is
showing the error 

"Only one top level element is allowed in an XML document. Error processing
resource"

pls help me out
 



--
View this message in context: http://camel.465427.n5.nabble.com/problem-in-aggregation-tp5717293.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: problem in aggregation

Posted by vasukfuse <va...@gmail.com>.
Hi Yogesh,

thanks for your reply.


I am tried based on your reply.

but  I am not  getting the output file.

It  thrwoing the following error.


*ShutdownTask] DefaultShutdownStrategy    INFO  Waiting as there are still 2
inflight and pending exchanges to complete, timeout in 299 seconds.
[el-1) thread #5 - ShutdownTask] DefaultShutdownStrategy        INFO 
Waiting as there are still 2 inflight and pending exchanges to complete,
timeout in 298 seconds.
[d #1 - AggregateTimeoutChecker] AggregateProcessor             WARN  Error
processing aggregated exchange. Exchange[null]. Caused by:
[org.apache.camel.component.file.GenericFileOperationFailedException -
Cannot store file: TESTOUTA\aggregate.xml]
Cannot store file: TESTOUTA\aggregate.xml
*


thanks

vasu.



--
View this message in context: http://camel.465427.n5.nabble.com/problem-in-aggregation-tp5717293p5718246.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: problem in aggregation

Posted by ychawla <pr...@yahoo.com>.
Hi,
Can you add some debug statements to your aggregator:

          newIn.setBody(oldBody + newBody); 

For example, what is oldBody and what is newBody?  Based on the error you
are receiving, you might be concatenating two XML documents like this:

<document1/>
<document2/>

This will not create a valid XML document because there will be two top
level elements.  You might try something like:

   newIn.setBody("<wrapper>" + oldBody + newBody + "</wrapper>");

Then you can strip the wrapper off in an XSLT or processor and combine the
two docs as they should be.

Thanks,
Yogesh 



--
View this message in context: http://camel.465427.n5.nabble.com/problem-in-aggregation-tp5717293p5717348.html
Sent from the Camel - Users mailing list archive at Nabble.com.