Quarkus: Document how to make Scheduler cron configurable via config

Created on 2 Nov 2019  ·  6Comments  ·  Source: quarkusio/quarkus

Description
I am using quarkus scheduler for a registration task for IoT devices in a smart city application. The task repeats every minute and retries to register if something went wrong before. It would be very helpful if I dont have to hardcode the cron into my services. Then i can repeat the task more often in dev mode and less often in production for example.

Implementation ideas
I think of a configuration key in the annotation like in microprofiles rest client @RegisterRestClient(configKey = "...").

@Scheduled(configKey = "registrationcron")
public void register() {
    //...
}
kinenhancement

Most helpful comment

The best feature requests are for non-documented features.
Thank you very much for your fast response and the example code 👍
As a test I worked for a private project with Quarkus and I am very satisfied. I'll suggest Quarkus at work.

All 6 comments

Hi @alexander-dammeier thanks for reporting this.

This can current be achieved with

@Scheduled(cron = "{registrationcron}")
public void register() {
    //...
}

With registrationcron property being the value in application.properties configuration file.

Is it documented somewhere? Do we have a test for it?

On Sat, Nov 2, 2019 at 11:53 AM Manyanda Chitimbo notifications@github.com
wrote:

Hi @alexander-dammeier https://github.com/alexander-dammeier thanks for
reporting this.

This can current be achieved with

@Scheduled(cron = "{registrationcron}")
public void register() {
//...
}

With registrationcron property being the application.properties
configuration file.


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
https://github.com/quarkusio/quarkus/issues/5126?email_source=notifications&email_token=AAJYOBNORIUBU6FJXEXLMSDQRVL3HA5CNFSM4JIERYQ2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEC4ZEGQ#issuecomment-549032474,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/AAJYOBKJZAFDMU75DRXXE6LQRVL3HANCNFSM4JIERYQQ
.

It is not documented, I was planning to get to it a bit later.

As for the test we have one example job here:
https://github.com/quarkusio/quarkus/blob/master/integration-tests/main/src/main/java/io/quarkus/it/scheduler/ExampleJobs.java#L27-L32

Cool, thanks!

The best feature requests are for non-documented features.
Thank you very much for your fast response and the example code 👍
As a test I worked for a private project with Quarkus and I am very satisfied. I'll suggest Quarkus at work.

@alexander-dammeier I am glad it worked for you. We'll have the feature documented for the next release hopefully.

Looking forward to hear your success story on using Quarkus in production ;-)

Was this page helpful?
0 / 5 - 0 ratings