RE: Zip all files available in folder - synchronously
Thanks Clause for the reply. So I assume there is no default approach via Camel Aggregator. What I have done currently is used Looping with reading from File Endpoint with maxPollMessage = 1. As we are using 2.16 version, the only way this loop based solution works if we know before-hand how many files exists. Will switch to do-while with 2.17 And I really didn't get how else - on demand we can trigger the route to start aggregating the files. Is there some other Camel Component which can help or you are proposing non-camel approach? Sorry it isn't clear to me. Regards, Arpit. -Original Message- From: Claus Ibsen [mailto:claus.ib...@gmail.com] Sent: Tuesday, November 1, 2016 3:41 AM To: users@camel.apache.org Subject: Re: Zip all files available in folder - synchronously You cannot do this the aggregate is in 2 different threads. Don't use the direct endpoint but do something different to trigger the route to start and aggreage those files, and then get an event when its done, which you can then use to know when the zip is ready. On Mon, Oct 31, 2016 at 11:04 PM, Goyal, Arpit <arpit.go...@sap.com> wrote: > Hi Colleagues, > > I want to read all file and aggregate into one single zip, but the batch > consumer always run in different thread. What needs to be done additionally > to get the response synchronously? > > Regards, > Arpit. > >DefaultCamelContext c = new DefaultCamelContext(); > try { > c.addRoutes(new RouteBuilder() { > > @Override > public void configure() throws Exception { > > from("direct:start").from("file:/tmp/wiretap/6443391d-196a-4c75-b2f8-9c0696025b56/?include=.*=true=2500") > .aggregate(body(), new > CustomZipAggregationStrategy()).completionFromBatchConsumer().to("file:/tmp/wiretap/aggregate"); > } > }); > > ProducerTemplate template = c.createProducerTemplate(); > c.start(); > template.start(); > template.requestBody("direct:start", "BEGIN"); //synchronously response > on completion of zip construction... > } finally { > c.stop(); > } > -- Claus Ibsen - http://davsclaus.com @davsclaus Camel in Action 2: https://www.manning.com/ibsen2
Re: Zip all files available in folder - synchronously
You cannot do this the aggregate is in 2 different threads. Don't use the direct endpoint but do something different to trigger the route to start and aggreage those files, and then get an event when its done, which you can then use to know when the zip is ready. On Mon, Oct 31, 2016 at 11:04 PM, Goyal, Arpitwrote: > Hi Colleagues, > > I want to read all file and aggregate into one single zip, but the batch > consumer always run in different thread. What needs to be done additionally > to get the response synchronously? > > Regards, > Arpit. > >DefaultCamelContext c = new DefaultCamelContext(); > try { > c.addRoutes(new RouteBuilder() { > > @Override > public void configure() throws Exception { > > from("direct:start").from("file:/tmp/wiretap/6443391d-196a-4c75-b2f8-9c0696025b56/?include=.*=true=2500") > .aggregate(body(), new > CustomZipAggregationStrategy()).completionFromBatchConsumer().to("file:/tmp/wiretap/aggregate"); > } > }); > > ProducerTemplate template = c.createProducerTemplate(); > c.start(); > template.start(); > template.requestBody("direct:start", "BEGIN"); //synchronously response > on completion of zip construction... > } finally { > c.stop(); > } > -- Claus Ibsen - http://davsclaus.com @davsclaus Camel in Action 2: https://www.manning.com/ibsen2
RE: Zip all files available in folder - synchronously
HI JB, Can you elaborate a little. At least the code I have written below, I always see Aggregation happening in separate thread and not main-thread. And which method you mean by stopping condition? Tried completionFromBatchConsumer and completionSize, without any luck. Regards, Arpit. -Original Message- From: Jean-Baptiste Onofré [mailto:j...@nanthrax.net] Sent: Monday, October 31, 2016 11:14 PM To: users@camel.apache.org Subject: Re: Zip all files available in folder - synchronously Hi Arpit, The aggregate should work for that. All depends on the "stopping condition". Regards JB On 10/31/2016 11:04 PM, Goyal, Arpit wrote: > Hi Colleagues, > > I want to read all file and aggregate into one single zip, but the batch > consumer always run in different thread. What needs to be done additionally > to get the response synchronously? > > Regards, > Arpit. > >DefaultCamelContext c = new DefaultCamelContext(); > try { > c.addRoutes(new RouteBuilder() { > > @Override > public void configure() throws Exception { > > from("direct:start").from("file:/tmp/wiretap/6443391d-196a-4c75-b2f8-9c0696025b56/?include=.*=true=2500") > .aggregate(body(), new > CustomZipAggregationStrategy()).completionFromBatchConsumer().to("file:/tmp/wiretap/aggregate"); > } > }); > > ProducerTemplate template = c.createProducerTemplate(); > c.start(); > template.start(); > template.requestBody("direct:start", "BEGIN"); //synchronously response > on completion of zip construction... > } finally { > c.stop(); > } > > -- Jean-Baptiste Onofré jbono...@apache.org http://blog.nanthrax.net Talend - http://www.talend.com
Re: Zip all files available in folder - synchronously
Hi Arpit, The aggregate should work for that. All depends on the "stopping condition". Regards JB On 10/31/2016 11:04 PM, Goyal, Arpit wrote: Hi Colleagues, I want to read all file and aggregate into one single zip, but the batch consumer always run in different thread. What needs to be done additionally to get the response synchronously? Regards, Arpit. DefaultCamelContext c = new DefaultCamelContext(); try { c.addRoutes(new RouteBuilder() { @Override public void configure() throws Exception { from("direct:start").from("file:/tmp/wiretap/6443391d-196a-4c75-b2f8-9c0696025b56/?include=.*=true=2500") .aggregate(body(), new CustomZipAggregationStrategy()).completionFromBatchConsumer().to("file:/tmp/wiretap/aggregate"); } }); ProducerTemplate template = c.createProducerTemplate(); c.start(); template.start(); template.requestBody("direct:start", "BEGIN"); //synchronously response on completion of zip construction... } finally { c.stop(); } -- Jean-Baptiste Onofré jbono...@apache.org http://blog.nanthrax.net Talend - http://www.talend.com
Zip all files available in folder - synchronously
Hi Colleagues, I want to read all file and aggregate into one single zip, but the batch consumer always run in different thread. What needs to be done additionally to get the response synchronously? Regards, Arpit. DefaultCamelContext c = new DefaultCamelContext(); try { c.addRoutes(new RouteBuilder() { @Override public void configure() throws Exception { from("direct:start").from("file:/tmp/wiretap/6443391d-196a-4c75-b2f8-9c0696025b56/?include=.*=true=2500") .aggregate(body(), new CustomZipAggregationStrategy()).completionFromBatchConsumer().to("file:/tmp/wiretap/aggregate"); } }); ProducerTemplate template = c.createProducerTemplate(); c.start(); template.start(); template.requestBody("direct:start", "BEGIN"); //synchronously response on completion of zip construction... } finally { c.stop(); }