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

KafkaStreams needs to be gracefully shutdown but has Autoclosable interface. #20

Open
kartius opened this issue Jun 16, 2021 · 1 comment

Comments

@kartius
Copy link

kartius commented Jun 16, 2021

I implemented a kafka streams application. And by the confluent example created a shutdown hook for the gracefully shutdown.

        final Topology topology = buildTopology();
        KafkaStreams kafkaStreams = new KafkaStreams(topology, properties);
        kafkaStreams.start();
        Runtime.getRuntime().addShutdownHook(new Thread(kafkaStreams::close));

This is working good. But from the other side I have a sonar cube complaining for the issue that I should create KafkaStreams using try-with-resources. But in this case kafka streams closed and isn't listening events. As I now in prevoious versions KafkaStreams didn't implement Autoclosable interface. What could you suggest to use gracefully shutdown and to avoid a sonar complaining? Or should I use gracefully shutdown and try-with-resources both?

@hitenny
Copy link

hitenny commented Feb 24, 2024

I am also facing this issue. Any update?

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

No branches or pull requests

2 participants