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?
I implemented a kafka streams application. And by the confluent example created a shutdown hook for the gracefully shutdown.
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?