1
votes
  1. I'm currently work at project where i need to allow user to create task which will be notified by him in specific date. IS there any method or library available in spring boot?

  2. Or maybe any idea how i can be able to make @Scheduled(value) with date(value) from user?

Like this:

@Scheduled(cron="*/5 * * * * MON-FRI")

To this

value="*/5 * * * * MON-FRI";
@Scheduled(cron=value)

2a. I think i need to create new class and for any user i should made new object? But how i can then delete/edit that value?

1

1 Answers

1
votes

The problem with the @Scheduled annotation in the usecase you described is that it creates an (asynchronous), "singleton-like" task. So it would only be one task doing it's work by the configured interval.

In addition to that the argument to configure the interval has to be present at compile / startup time depending on which fields (fixedDelay, fixedDelayString) you are using.

One way to create tasks dynamically is using task executors and (cron) triggers.

Take a look here: https://docs.spring.io/spring/docs/current/spring-framework-reference/html/scheduling.html