You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by christoffer <ch...@k15t.com> on 2013/10/09 14:50:11 UTC
Consume files periodically or on demand
Hi,
I have a route which uses the file:// component to consume files from a
directory. The polling interval will be quite large, between 8 hours and a
day. But now the customer added a new requirement to also consume the files
on demand - i.e. when he clicks a button. The periodical consumption should
still work.
Now my question is: Is there a smart way to do this with Camel, e.g. send a
trigger message or alike?
I am using Camel 2.11.0 and Java 6 (Oracle). I have used the Java DSL with
CamelRouteBuilder to configure my routes.
Thanks in advance to all camel riders - cheers Chris
--
View this message in context: http://camel.465427.n5.nabble.com/Consume-files-periodically-or-on-demand-tp5741235.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: Consume files periodically or on demand
Posted by Pontus Ullgren <ul...@gmail.com>.
You could create the file consuming route with autoStart(false). Then have
a separate "controller" route that starts the first route on incoming
message.
Have a look at the Controlbus EIP[1]
[1] http://camel.apache.org/controlbus.html
// Pontus
On Wed, Oct 9, 2013 at 10:09 PM, christoffer <ch...@k15t.com> wrote:
> Hi,
>
> thank you very much for your great input.
> I tried using the approach with pollEnrich - but that only consumes one
> file
> from the (potentially) many files.
>
> I figured out the following approach using pollEnrich
> from(demandFileConsumption).pollEnrich(fileEndpointName +
> "?sendEmptyMessageWhenIdle=true").choice()
> .when(body().isNull()).stop()
> .otherwise().wireTap(demandFileConsumption, false,
> constant("trigger")).to("mock:result").endChoice();
>
> demandFileConsumption is direct endpoint URI and fileEndpointName is a file
> endpoint URI. When I send a message to demandFileConsumption, this will
> consume the first file, which in turn trigger the consumption of the next
> file via the wireTap. If the source directory is drained of files the
> content based router shuts down the polling for files.
> This seems to work; is there a cleaner or more "camelish" approach. I think
> using the approach would basically be the same idea.
> Thanks for your input and keep ridin', chris
>
>
>
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/Consume-files-periodically-or-on-demand-tp5741235p5741247.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
Re: Consume files periodically or on demand
Posted by christoffer <ch...@k15t.com>.
Hi,
thank you very much for your great input.
I tried using the approach with pollEnrich - but that only consumes one file
from the (potentially) many files.
I figured out the following approach using pollEnrich
from(demandFileConsumption).pollEnrich(fileEndpointName +
"?sendEmptyMessageWhenIdle=true").choice()
.when(body().isNull()).stop()
.otherwise().wireTap(demandFileConsumption, false,
constant("trigger")).to("mock:result").endChoice();
demandFileConsumption is direct endpoint URI and fileEndpointName is a file
endpoint URI. When I send a message to demandFileConsumption, this will
consume the first file, which in turn trigger the consumption of the next
file via the wireTap. If the source directory is drained of files the
content based router shuts down the polling for files.
This seems to work; is there a cleaner or more "camelish" approach. I think
using the approach would basically be the same idea.
Thanks for your input and keep ridin', chris
--
View this message in context: http://camel.465427.n5.nabble.com/Consume-files-periodically-or-on-demand-tp5741235p5741247.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: Consume files periodically or on demand
Posted by James Carman <ja...@carmanconsulting.com>.
Try pollEnrich() and have two ways of kicking off your route, one
would be with a timer of some sort (the every 8 hours). The other
would be a JMS queue or direct or seda or something.
On Wed, Oct 9, 2013 at 8:50 AM, christoffer <ch...@k15t.com> wrote:
> Hi,
>
> I have a route which uses the file:// component to consume files from a
> directory. The polling interval will be quite large, between 8 hours and a
> day. But now the customer added a new requirement to also consume the files
> on demand - i.e. when he clicks a button. The periodical consumption should
> still work.
> Now my question is: Is there a smart way to do this with Camel, e.g. send a
> trigger message or alike?
>
> I am using Camel 2.11.0 and Java 6 (Oracle). I have used the Java DSL with
> CamelRouteBuilder to configure my routes.
>
> Thanks in advance to all camel riders - cheers Chris
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Consume-files-periodically-or-on-demand-tp5741235.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
Re: Consume files periodically or on demand
Posted by Christian Müller <ch...@gmail.com>.
I suggest to use the ConsumerTemplete which can read the file and send it
afterwards to a direct consumer which ia also used by the existing route.
Best,
Christian
Am 09.10.2013 14:50 schrieb "christoffer" <ch...@k15t.com>:
> Hi,
>
> I have a route which uses the file:// component to consume files from a
> directory. The polling interval will be quite large, between 8 hours and a
> day. But now the customer added a new requirement to also consume the files
> on demand - i.e. when he clicks a button. The periodical consumption should
> still work.
> Now my question is: Is there a smart way to do this with Camel, e.g. send a
> trigger message or alike?
>
> I am using Camel 2.11.0 and Java 6 (Oracle). I have used the Java DSL with
> CamelRouteBuilder to configure my routes.
>
> Thanks in advance to all camel riders - cheers Chris
>
>
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/Consume-files-periodically-or-on-demand-tp5741235.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>