You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Hilde <hi...@yahoo.de> on 2012/08/03 15:21:31 UTC
Polling consumer: how to recognize an empty directory
Hello folks!
We create a polling consumer route via a dynamic router. When the transfer
is finished we recognize the end
by the header /CamelBatchComplete/ and we are able to stop the route. But
imagine the case when the directory of polling is empty. How can I find out
that to stop the route rapidly?
Cheers
Hilde
--
View this message in context: http://camel.465427.n5.nabble.com/Polling-consumer-how-to-recognize-an-empty-directory-tp5716761.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: Polling consumer: how to recognize an empty directory
Posted by Henryk Konsek <he...@gmail.com>.
> In Camel >= 2.0 "sendEmptyMessageWhenIdle" is a way to go :)
*2.9
--
Henryk Konsek
http://henryk-konsek.blogspot.com
Re: Polling consumer: how to recognize an empty directory
Posted by Henryk Konsek <he...@gmail.com>.
> Not with filter but I can check file name in some processor.
Ok, I get it :) I was wondering whether is it possible to achieve this
behavior with File component only.
Laters.
--
Henryk Konsek
http://henryk-konsek.blogspot.com
Re: Polling consumer: how to recognize an empty directory
Posted by "michal.warecki" <mi...@gmail.com>.
Not with filter but I can check file name in some processor.
"sendEmptyMessageWhenIdle" is almost the same idea but is automatic and
doesn't produce message when files are in the directory. It is of course
better solution.
--
View this message in context: http://camel.465427.n5.nabble.com/Polling-consumer-how-to-recognize-an-empty-directory-tp5716761p5716781.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: Polling consumer: how to recognize an empty directory
Posted by Henryk Konsek <he...@gmail.com>.
> Just an idea:
>
> - before pooling, create a file with specified name, for example
> /TEST-POOLING/ and skip this file while processing. If there is only test
> file in directory, you will get /CamelBatchComplete/.
>
> - simpler: before starting the route, check if there is any file in
> particular directory :-)
I would not recommend such workarounds in Camel >= 2.9 since (as Achim
said) we got "sendEmptyMessageWhenIdle" to indicate that the directory
is empty. In Camel >= 2.0 "sendEmptyMessageWhenIdle" is a way to go :)
.
BTW MichaĆ, How exactly you want to skip file from the processing? If
you exclude it with filter and it is only file in the directory, you
will got no message at all. :)
--
Henryk Konsek
http://henryk-konsek.blogspot.com
Re: Polling consumer: how to recognize an empty directory
Posted by "michal.warecki" <mi...@gmail.com>.
Just an idea:
- before pooling, create a file with specified name, for example
/TEST-POOLING/ and skip this file while processing. If there is only test
file in directory, you will get /CamelBatchComplete/.
- simpler: before starting the route, check if there is any file in
particular directory :-)
--
View this message in context: http://camel.465427.n5.nabble.com/Polling-consumer-how-to-recognize-an-empty-directory-tp5716761p5716762.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: Polling consumer: how to recognize an empty directory
Posted by Hilde <hi...@yahoo.de>.
Many thanks, the option /sendEmptyMessageWhenIdle/ helped for me.
Inside the route I can check the empty message as you can see below:
.choice()
.when(body().isNull())
.setHeader(CamelHeader.ANY_MESSAGE, simple("Directory is empty and transfer
is going to finish!"))
.to("seda:" + SedaDirectDestinations.SEDA_INFOS_WHILE_TRANSFER)
.bean(stopRoute)
.otherwise()
... // transfer as usual
Have a nice weekend!
Hilde
--
View this message in context: http://camel.465427.n5.nabble.com/Polling-consumer-how-to-recognize-an-empty-directory-tp5716761p5716769.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: Polling consumer: how to recognize an empty directory
Posted by Achim Nierbeck <bc...@googlemail.com>.
Hi Hilde,
there is this flag "sendEmptyMessageWhenIdle"
to set on the file endpoint. This way you can tell wether the route is
idling and therefore are able to stop.
regards, Achim
2012/8/3 Hilde <hi...@yahoo.de>:
> Hello folks!
>
> We create a polling consumer route via a dynamic router. When the transfer
> is finished we recognize the end
> by the header /CamelBatchComplete/ and we are able to stop the route. But
> imagine the case when the directory of polling is empty. How can I find out
> that to stop the route rapidly?
>
> Cheers
> Hilde
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Polling-consumer-how-to-recognize-an-empty-directory-tp5716761.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
--
Apache Karaf <http://karaf.apache.org/> Committer & PMC
OPS4J Pax Web <http://wiki.ops4j.org/display/paxweb/Pax+Web/>
Committer & Project Lead
OPS4J Pax for Vaadin
<http://team.ops4j.org/wiki/display/PAXVAADIN/Home> Commiter & Project
Lead
blog <http://notizblog.nierbeck.de/>