Skip to content

Disable the Schedule (@Scheduled) based on configuration property #10812

@adrianpunga

Description

@adrianpunga

Helidon Version: V4 (latest)

Enhancement Description

As per existing documentation (https://helidon.io/docs/v4/mp/scheduling), there is no option to disable the scheduling based on configuration property (eg. schedule.enabled: false) during the application startup, like in other frameworks (Spring: @scheduled(cron = Scheduled.CRON_DISABLED).

I'm aware of the workaround of configuring the cron values in a way that the execution are delayed / or never executes:
cron: "0 0 0 ? 12 7 2099" or cron: "0 0 0 31 2 ?":

com.example.mp.app.init:
schedule:
cron: "0 0 0 31 2 ?"

but in my opinion this is misleading for a production environment as the the scope of setting a cron is for the scheduler to execute at that specific date, not the opposite.

Solution (more intuitive):

application.yaml
com.example.mp.app.init:
schedule:
enabled: false

Similar approach is used for other capabilities in Helidon: e.g. metrics.enabled: false

Thanks,
Adrian

Metadata

Metadata

Labels

4.xVersion 4.xP3enhancementNew feature or request

Projects

Status

Sprint Scope

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions