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

Tasks submitted to executor during deployment executed after deployment. #24540

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

OndroMih
Copy link
Contributor

@OndroMih OndroMih commented Aug 11, 2023

An improvement of #24539.

If tasks submitted during deployment, e.g. in @initialized(ApplicationScoped.class) observer, they are added to a queue in the deployment context and triggered after deployment finished. This draft currently modifies the ManagedExecutorService to execute tasks after deployment complete. It doesn't modify ManagedScheduledExecutorService.

Description of the solution:

  1. Application lifecycle listener creates storage for tasks when deployment starts
  2. Executor detects that storage exists in deployment context (deployment is not complete) - it won't execute tasks immediately but will add tasks to the storage
  3. When deployment completes, application lifecycle listener executes the tasks from the storage and removes storage.
  4. Executor no longer detects storage and executes the tasks immediately

To do:

  • Implement also for scheduled executor service
  • Add some logging
  • An option to trigger tasks immediately during deployment, or trigger tasks immediately for plain executor and only delay with scheduled executor (the logic is that tasks are scheduled after deployment) - there are multiple options, see below
  • tests (task submitted during deployment is triggered after startup method completes, task submitted after deployment triggers immediately)

There are multiple options to implement this whole feature:

  • execute all tasks after deployment
  • execute only tasks submitted by scheduled executor after deployment but tasks submitted by plain executor immediately (the logic is tasks should be scheduled to execute after deployment and thus should be submitted by a scheduled executor)
  • support an option on the executor or deployment descriptor to switch the behavior - either execute immediately or execute after deployment completes.

If tasks submitted during deployment, e.g. in @initialized(ApplicationScoped.class) observer,
they are added to a queue in the deployment context and triggered after deployment finished.

To do:

* Implement also for scheduled executor service
* Add some logging
* An option to trigger tasks immediately during deployment,
or trigger tasks immediately for plain executor and only delay with scheduled executor
(the logic is that tasks are scheduled after deployment)
* tests (task submitted during deployment is triggered after startup method completes)
Signed-off-by:Ondro Mihalyi <mihalyi@omnifish.ee>
After introducing a subtype of ManagedExecutorServiceImpl
Signed-off-by:Ondro Mihalyi <mihalyi@omnifish.ee>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant