git.net

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Run route and then stop context


Hi

Yeah or if you use Main to startup Camel you can configure its
duration options to number of max messages, time, etc.
http://static.javadoc.io/org.apache.camel/camel-core/2.20.2/org/apache/camel/Main.html

On Thu, Mar 15, 2018 at 3:11 PM, Kris Easter <kris.easter@xxxxxxxxxxxx> wrote:
>
> I'm just getting started with using Camel and integrating it for new work
> into an existing batch based legacy workflow.  It seems easiest, for now, to
> use in the legacy workflow if we can execute the Camel job and then
> completely exit.
>
> This seems to accomplish that:
>
> from("timer://runOnce?repeatCount=1").to("direct:doTheWork")
>  .onCompletion().parallelProcessing().to("direct:shutdown");
>
>
> from("direct:shutdown").id("shutdownRoute").process(new Processor() {
>   @Override
>   public void process(Exchange exchange) throws Exception {
>
>     getContext().getShutdownStrategy().setTimeout(60);
>
>     getContext().getShutdownStrategy()
>       .setLogInflightExchangesOnTimeout(false);
>
>     getContext().stop();
>
>     }
> });
>
>
> Is there a better way to accomplish this?  Are there hidden dangers in the
> approach above?
>
> Thanks,
> Kris
>



-- 
Claus Ibsen
-----------------
http://davsclaus.com @davsclaus
Camel in Action 2: https://www.manning.com/ibsen2



( ! ) Warning: include(msgfooter.php): failed to open stream: No such file or directory in /var/www/git/apache-camel-users/msg03147.html on line 117
Call Stack
#TimeMemoryFunctionLocation
10.0017364576{main}( ).../msg03147.html:0

( ! ) Warning: include(): Failed opening 'msgfooter.php' for inclusion (include_path='.:/var/www/git') in /var/www/git/apache-camel-users/msg03147.html on line 117
Call Stack
#TimeMemoryFunctionLocation
10.0017364576{main}( ).../msg03147.html:0