Skip to content
This repository was archived by the owner on Jan 19, 2022. It is now read-only.

spring-cloud-gcp-starter-pubsub not shutting down #1503

Closed
danneville opened this issue Mar 5, 2019 · 4 comments
Closed

spring-cloud-gcp-starter-pubsub not shutting down #1503

danneville opened this issue Mar 5, 2019 · 4 comments
Assignees
Labels
pubsub GCP PubSub

Comments

@danneville
Copy link

Hi,

I'm experiencing some issues using spring-cloud-gcp-starter-pubsub where the application hangs on shutdown. It sounds the same as this issue #60 which was closed when it wasn't able to be reproduced.

I have created a Spring CommandLineRunner Application that will publish messages to PubSub and then shutdown however it does not. I've provided the bare minimum to reproduce here https://github.com/danneville/spring-gcp-pub-sub-issue . Just the inclusion of the spring-cloud-gcp-starter-pubsub dependency causes the application to hang on shutdown. If you remove the dependency it shuts down immediately as expected.

This happens both when running the application in IntelliJ and on the command line.

I've provided the thread dump in the repo if this helps.

Please can you confirm if this is an issue or if I should be specifying something to gracefully shutdown?

Many thanks

@elefeint elefeint self-assigned this Mar 5, 2019
@elefeint elefeint added the pubsub GCP PubSub label Mar 5, 2019
@dmitry-s
Copy link
Contributor

dmitry-s commented Mar 5, 2019

Thanks for reporting the issue!
I was able to reproduce it using your sample app. We will take a look.

@dmitry-s
Copy link
Contributor

dmitry-s commented Mar 5, 2019

We identified the issue, will push a fix shortly.

@elefeint
Copy link
Contributor

elefeint commented Mar 6, 2019

@danneville This has been fixed in 1.2.0.BUILD-SNAPSHOT, but if using a snapshot version is not an option, you can close the thread pool like this:

@SpringBootApplication
public class SampleApplication implements CommandLineRunner {

    @Autowired
    @Qualifier("subscriberExecutorProvider")
    ExecutorProvider subscriberExecutorProvider;

    @PreDestroy
    public void shutdownExecutor() {
        this.subscriberExecutorProvider.getExecutor().shutdown();
    }

    public static void main(String[] args) {
        // ... original logic
    }
}

@danneville
Copy link
Author

Excellent thank you @elefeint amd @dmitry-s for you quick responses.

I can confirm that this worked for me. I did also have to add the publisherExecutorProvider to get it to work for when I'm publishing messages.

    @Autowired
    @Qualifier("subscriberExecutorProvider")
    private ExecutorProvider subscriberExecutorProvider;

    @Autowired
    @Qualifier("publisherExecutorProvider")
    private ExecutorProvider publisherExecutorProvider;

    @PreDestroy
    public void shutdownExecutor() {
        this.subscriberExecutorProvider.getExecutor().shutdown();
        this.publisherExecutorProvider.getExecutor().shutdown();
    }

Thanks again

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
pubsub GCP PubSub
Development

No branches or pull requests

3 participants