question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[quarkus-quartz] `cron` expression of `@Scheduled` is not updated via ENV (overwriting application.properties)

See original GitHub issue

Describe the bug

Given

  • @Scheduled(identity = "aJob", cron = "{a.job.schedule.cron}") in code
  • a.job.schedule.cron=0 0 1 * * ? * in application.properties and
  • A_JOB_SCHEDULE_CRON=0 0 1 * * ? 2100 in ENV

if the application has been started prior without the ENV part, restarting the application with ENV doesn’t update the field cron_expression in the table qrtz_cron_triggers.

if the application has not been started prior without the ENV part, starting it the first time with ENV leads to cron_expression being filled with the cron expression from ENV, not from application.properties (as expected).

Expected behavior

Field cron_expression in the table qrtz_cron_triggers is updated.

Alternatively, this behaviour is documented on the https://quarkus.io/guides/quartz and there is a way to overwrite existing cron expressions using ENV.

Actual behavior

Field cron_expression in the table qrtz_cron_triggers is not updated.

How to Reproduce?

No response

Output of uname -a or ver

Microsoft Windows [Version 10.0.18363.1766]

Output of java -version

11.0.10

GraalVM version (if different from Java)

No response

Quarkus version or git rev

2.2.1.Final

Build tool (ie. output of mvnw --version or gradlew --version)

Apache Maven 3.8.1

Additional information

No response

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
coiouhkccommented, Oct 6, 2021

I’ve built the partial 999-SNAPSHOT with mvn install -DskipTests -am -pl :quarkus-quartz, replaced quarkus-quartz version in the guided application and it worked like a charm:

  • restarting with updated application.properties worked and updated the cron definition in the DB
  • restarting with updated application.properties and additional ENV took proper precedence and updated the cron definition in the DB according to ENV

Thanks for the quick fix @machi1990 !

1reaction
coiouhkccommented, Oct 5, 2021

I’ve a quick fix which will add the rescheduling part but I’d like @coiouhkc to have a test.

@machi1990 - thanks for the quick reply, i’ll try it out tomorrow.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Scheduler Reference Guide - Quarkus
The syntax used in CRON expressions is controlled by the quarkus.scheduler.cron-type property. The values can be cron4j , quartz , unix and spring...
Read more >
Scheduling Periodic Tasks with Quartz - Quarkus
Modern applications often need to run specific tasks periodically. In this guide, you learn how to schedule periodic clustered tasks using the Quartz...
Read more >
Scheduling Periodic Tasks - Quarkus
Modern applications often need to run specific tasks periodically. In this guide, you learn how to schedule periodic tasks.
Read more >
All configuration options - Quarkus
AWS Lambda Type Default AWS Lambda Common Type Default AWS Lambda Gateway REST API Type Default Agroal ‑ Database connection pool Type Default
Read more >
Scheduling Periodic Tasks with Quartz - Quarkus
Inject the underlying org.quartz.Scheduler instance. 2, Schedule a new job using the Quartz API. 3, Invoke the TaskBean#performTask() method from the job.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found