camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Claus Ibsen <claus.ib...@gmail.com>
Subject Re: Zip all files available in folder - synchronously
Date Tue, 01 Nov 2016 10:40:43 GMT
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.goyal@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=.*&delete=true&maxMessagesPerPoll=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

Mime
View raw message