You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by zzkozak <ma...@pikula.de> on 2014/07/03 17:25:26 UTC

How to call a bean after all files has been processed?

I wrote the following route and expected that the bean 'teaserService' should
be called only one time, at the end of processing of all files, but ... it's
called after processing of each file:

How to achieve such a behavior?

Thanks



--
View this message in context: http://camel.465427.n5.nabble.com/How-to-call-a-bean-after-all-files-has-been-processed-tp5753293.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: How to call a bean after all files has been processed?

Posted by Christian Müller <ch...@gmail.com>.
This is the intended behavior.

To achieve the behavior you want, I propose the followings:
- use the file consumers Exchange property "CamelBatchComplete" [1] to know
which file is the last one
- use an Aggregator [2] with a custom completion Predicate before you are
calling your "teaserService"

[1] http://camel.apache.org/file2.html
[2] http://camel.apache.org/aggregator2.html

Best,

Christian
-----------------

Software Integration Specialist

Apache Member
V.P. Apache Camel | Apache Camel PMC Member | Apache Camel committer
Apache Incubator PMC Member

https://www.linkedin.com/pub/christian-mueller/11/551/642


On Thu, Jul 3, 2014 at 5:25 PM, zzkozak <ma...@pikula.de> wrote:

> I wrote the following route and expected that the bean 'teaserService'
> should
> be called only one time, at the end of processing of all files, but ...
> it's
> called after processing of each file:
>
> How to achieve such a behavior?
>
> Thanks
>
>
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/How-to-call-a-bean-after-all-files-has-been-processed-tp5753293.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>

Re: How to call a bean after all files has been processed?

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

See about the batch completed property you can use to know when the
batch of files is complete
http://camel.apache.org/batch-consumer.html

And this has been debated before on these forums so you can make
search and find that.

On Thu, Jul 3, 2014 at 5:25 PM, zzkozak <ma...@pikula.de> wrote:
> I wrote the following route and expected that the bean 'teaserService' should
> be called only one time, at the end of processing of all files, but ... it's
> called after processing of each file:
>
> How to achieve such a behavior?
>
> Thanks
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/How-to-call-a-bean-after-all-files-has-been-processed-tp5753293.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
Red Hat, Inc.
Email: cibsen@redhat.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen
hawtio: http://hawt.io/
fabric8: http://fabric8.io/