Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Use Case]: More Control on Scheduled #640

Open
1 of 4 tasks
hantsy opened this issue Dec 11, 2024 · 3 comments
Open
1 of 4 tasks

[Use Case]: More Control on Scheduled #640

hantsy opened this issue Dec 11, 2024 · 3 comments
Labels
enhancement New feature or request

Comments

@hantsy
Copy link

hantsy commented Dec 11, 2024

As a ...

  • Application user/user of the configuration itself
  • API user (application developer)
  • SPI user (container or runtime developer)
  • Specification implementer

I need to be able to ...

The @Asynchronous(runAt=) lacks several features from the existing Spring and EJB.

Which enables me to ...

Add the following attributes to the @Scheduled annotations.

  1. initial delay
  2. fixed delay between intervals
  3. if start the next running when the last running is not finished
  4. Only run once.
  5. @Timeout replacement from EJB

Additional information

@hantsy hantsy added the enhancement New feature or request label Dec 11, 2024
@hantsy hantsy changed the title [Use Case]: More Control on Schedule [Use Case]: More Control on Scheduled Dec 11, 2024
@njr-11
Copy link
Contributor

njr-11 commented Dec 11, 2024

4. Only run once.

The current API already offers this. The first paragraph of the Javadoc for runAt states: "The Jakarta EE product attempts to run the method at the scheduled times until its future is completed or the method returns a non-null result value or raises an exception." The asynchronous method can choose any of these 3 ways to make itself only run once.

  1. @Timeout replacement from EJB

The aspect that we are aware of that is still needed is to automatically submit/schedule the asynchronous method upon application startup. We have issue #624 to add that. If there is some other capability that you are aware of that is lacking, or if you were asking for other capability of EJB timers that we don't have in Jakarta Concurrency like persistent timers, please be specific about identifying what it is. Otherwise, I will assume 624 adequately covers this requirement.

  1. if start the next running when the last running is not finished

This is very poorly written, so I can only guess what you are proposing. Are you asking to have overlapping executions of the same asynchronous method such that if one method is scheduled to run every 5 seconds and the first execution takes 18 seconds and the second execution takes 8 seconds, then the first, second, and third executions will all be running at the same time? This would burden the application with needing to write the asynchronous method in a way that is tolerant of overlapping execution. The Concurrency specification has always tried to avoid that sort of usage, and I am unaware of any important use cases that would justify us adding in that complexity, so currently I would vote against this and would need a lot of convincing why it is a good idea.

  1. initial delay
  2. fixed delay between intervals

ManagedScheduledExecutorService already has initial delay, and fixed delay, (as well as another option called fixed rate, and also the ability to provide custom business logic for computing delays). This capability is used programmatically rather than via the Asynchronous annotation. Do you have an important use case behind why an application needs to be able to specify these delays on Asynchronous rather than programmatically as is currently possible? And if so, why fixed delay vs the other patterns like fixed rate or custom delays?

@hantsy
Copy link
Author

hantsy commented Dec 12, 2024

Do you have an important use case behind why an application needs to be able to specify these delays on Asynchronous rather than programmatically as is currently possible? And if so, why fixed delay vs the other patterns like fixed rate or custom delays?

I hope the annotations declaration in our spec has equivalent programmatic approaches, and implements the same features.

This means more options for end users. Finally, we can select creating a Jakarta EE application using a functional programming model or by annotation declaration.

@hantsy
Copy link
Author

hantsy commented Dec 12, 2024

Are you asking to have overlapping executions of the same asynchronous method such that if one method is scheduled to run every 5 seconds and the first execution takes 18 seconds and the second execution takes 8 seconds, then the first, second, and third executions will all be running at the same time?

yes, hope there are some options for users to select

  • run as scheduled and allow them to be executed in parallel
  • wait for previous is completed(done or exception) and run in queue
  • Skip running the next task if the previous task is not finished.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants