On Fri, Feb 2, 2024 at 11:17 AM Maarten Donderwinkel
<maarten.donderwin...@aiden.eu.invalid> wrote:

> We run a couple of Camel applications that utilize a K8S Cronjob.
>
>
>
> For our case we can auto shutdown the application with the property
> camel.main.durationMaxIdleSeconds.
>
> It’ll shutdown if the application is idle for a number of seconds.
>
> Your use-case and desired ‘trigger’ might be different of course, but
> there are more options to auto shutdown
>
>
>
> See https://camel.apache.org/components/4.0.x/others/main.html for more
> information on that property and how to set it.
>

Thanks Maarten, it could be an interesting approach. Wasn't aware of those
configuration. I'll experiment with them as well.


>
>
> Met vriendelijke groet | Kind Regards | Meilleures salutations | Mit
> freundlichen Grüβen,
>
> Maarten Donderwinkel
>
> Aiden Locatie Den Bosch [image: Email] maarten.donderwin...@aiden.eu
> www.aiden.eu
> <https://www.aiden.eu/?utm_source=aidenemailsignature&utm_medium=email>  Het
> Zuiderkruis 61
> 5215 MV 's-Hertogenbosch
>  +31 (0) 88 060 5111
>
>  +31 (0) 6 8683 0832
>
> [image: facebook.png] <https://www.facebook.com/weareAiden.eu> [image:
> linkedin.png] <https://www.linkedin.com/company/aiden-eu> [image: Twitter]
> <https://twitter.com/weareAiden> [image: youtube]
> <https://www.youtube.com/channel/UCcLccRfot11DrZLNhlAS8fA>
> <https://www.youtube.com/channel/UCcLccRfot11DrZLNhlAS8fA>
> <https://www.aiden.eu/>
> <https://www.aiden.eu/?utm_source=aidenemailsignature&utm_medium=email>
> <https://www.twitter.com/user_name_here>
> <https://www.youtube.com/user/user_name_here>
>
>
> *From: *Pasquale Congiusti <pasquale.congiu...@gmail.com>
> *Date: *Friday, 2 February 2024 at 11:08
> *To: *dev <dev@camel.apache.org>, us...@camel.apache.org <
> us...@camel.apache.org>
> *Subject: *How to make Camel cloud cron "friendly"
>
> Hi folks,
> I'm working lately on some experiment to run a generic Camel application on
> a Kubernetes CronJob. The behavior expected by the cluster is that, once
> the job workload is over, the application would exit with either a success
> or error code. As we're running a Camel application, although the route may
> have finished, the entire application will continue to run until a forceful
> shutdown. I am not sure it exists any other way, so I found my way to
> workaround this behavior by following the approach in [1], which would ends
> up in something like the following code:
>
> public class TestCron extends RouteBuilder {
>     @Override
>     public void configure() throws Exception {
>         from("timer:cron?delay=0&period=1&repeatCount=1")
>         // Simulate heavylift work
>         .delay(10000)
>         .to("log:info")
>         .log("DONE!")
>         .process(new Processor() {
>             Thread stop;
>             @Override
>             public void process(final Exchange exchange) throws Exception {
>                 if (stop == null) {
>                     stop = new Thread() {
>                         @Override
>                         public void run() {
>                             try {
>                                 exchange.getContext().stop();
>                             } catch (Exception e) {
>                                 // ignore
>                             }
>                         }
>                     };
>                 }
>                 // start the thread that stops the context
>                 stop.start();
>             }
>         });
>     }
> }
>
> However, this workaround feels a bit too hacky as it involves playing with
> Camel Context directly. It is also impossible to reproduce easily in non
> Java DSL, like in YAML. I am wondering if we can think on having a higher
> level EIP such we have with "stop", something like "shutdown" which
> behavior may be similar of what described above, taking care to gracefully
> shutdown the application when it is invoked. This one may do some finer
> grained controls to verify that the exchanges has really completed or there
> are no others routes running or any other low level check that would
> perform a controlled shutdown. How does it sound? or which would be any
> alternative to make Camel more cloud cron "friendly"?
>
> Regards,
> Pasquale.
>
> [1]
>
> https://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fcamel.apache.org%2Fmanual%2Ffaq%2Fhow-can-i-stop-a-route-from-a-route.html%23HowcanIstoparoutefromaroute-Usingathreadtostoparoutefromaroute&data=05%7C02%7Cmaarten.donderwinkel%40aiden.eu%7C9549aaebd583438beb6608dc23d6d5dc%7Cb9d83e0e2e894f4e9c2bbe3df185e1af%7C0%7C0%7C638424652819450381%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C0%7C%7C%7C&sdata=Gbf%2F8vAkywA7et%2FBR12uqs1OqTNFeP7Saaqm6jJHCzg%3D&reserved=0
> <https://camel.apache.org/manual/faq/how-can-i-stop-a-route-from-a-route.html#HowcanIstoparoutefromaroute-Usingathreadtostoparoutefromaroute>
>

Reply via email to