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

Allow to set the phase for MessageListenerContainer related to the SmartLifecycle interface on 3.0.0+ #693

Closed
estigma88 opened this issue Feb 27, 2023 · 3 comments
Labels
component: sqs SQS integration related issue type: enhancement Smaller enhancement in existing integration

Comments

@estigma88
Copy link
Contributor

Type: Feature

Is your feature request related to a problem? Please describe.
With previous versions of Spring Could AWS (No Spring Boot 3), we had troubles with the graceful shutdown process in Spring Boot. We have an application with the following components:

  • SqsListener
  • Quartz Scheduler

Seems like when the application is shutting down, SQS components and Quartz Scheduler components, have the same SmartLifecycle.phase, and they collide, causing Quartz to not shutting down completely, and letting some crons in the database corrupted.

The workaround we found was the following:

    @Bean
    fun beanXXXX(
       simpleMessageListenerContainer: SimpleMessageListenerContainer
    ): String {
        /**
         * SQS and Quartz seem having the same shutdown priority,
         * which causes problems with Quartz and cannot shutdown fine.
         *
         * phase = Integer.MAX_VALUE - 1 tells SQS to shutdown before Quartz.
         */
        simpleMessageListenerContainer.phase = Integer.MAX_VALUE - 1
        return "ok"
    }

Moving SQS components one phase before, guarantee SQS shutdowns first, and later, Quartz.

Describe the solution you'd like
A way to set the phase for the SmartLifecycle interface for 3.0.0+

Describe alternatives you've considered

  • Testing again the collision with the latest version and see if the cron problem still appears.
  • Going the rabbit hole and trying to find what's happening under the hood with this collision.

Additional context
I will try to create a minimal project to reproduce the issue, but it is environment dependent, not sure I can make it.

@maciejwalkowiak maciejwalkowiak added component: sqs SQS integration related issue type: enhancement Smaller enhancement in existing integration labels Mar 1, 2023
@tomazfernandes tomazfernandes removed their assignment May 17, 2023
@tomazfernandes
Copy link
Contributor

Hi @estigma88, sorry for the delay - I wanted 3.0.0 to be out before making many more modifications to the SQS code.

Would you like to contribute a PR for this feature?

@estigma88
Copy link
Contributor Author

Sure, I can give it a try. Let me come back with one MR for this.

@tomazfernandes
Copy link
Contributor

Closed by #821.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: sqs SQS integration related issue type: enhancement Smaller enhancement in existing integration
Projects
None yet
Development

No branches or pull requests

3 participants