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

Support spring 6.1.x lifecycle changes/late-shutdown for pubsub publisher scheduler #2738

Merged

Conversation

jayakumarc
Copy link
Contributor

There has been a significant revision of ThreadPoolTaskScheduler/Executor lifecycle capabilities as part of the spring-6.1.x release. It includes a concurrently managed stop phase for ThreadPoolTaskScheduler/Executor, favouring early soft shutdown. As a result, the ThreadPoolTaskScheduler, which is used for pubsub publishing, now shuts down immediately on ContextClosedEvent, thereby rejecting any further task submissions (#2721).

This PR aims to retain the default behavior of spring-6.1.x but provides config options to leverage the lateShutdown of the underlying ThreadPoolTaskScheduler, such as:
spring.cloud.gcp.pubsub.publisher.executor-accept-tasks-after-context-close=true.

References:

  1. Graceful shutdown does not cancel @Scheduled tasks spring-projects/spring-framework#32109 (comment)
  2. spring-projects/spring-framework@b12115b
  3. spring-projects/spring-framework@a2000db
  4. ScheduledAnnotationBeanPostProcessor: graceful shutdown should not interrupt currently running jobs spring-projects/spring-framework#31019 (comment)
  5. https://github.com/spring-projects/spring-framework/blob/996e66abdbaad866f0eab40bcf5628cdea92e046/spring-context/src/main/java/org/springframework/scheduling/concurrent/ExecutorConfigurationSupport.java#L482

@jayakumarc jayakumarc requested a review from a team as a code owner March 26, 2024 20:44
Copy link

google-cla bot commented Mar 26, 2024

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

Copy link

sonarcloud bot commented Mar 27, 2024

@meltsufin meltsufin merged commit 13e4911 into GoogleCloudPlatform:main Mar 28, 2024
12 checks passed
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

3 participants