Stop the Kafka Streams app

Is it possible to have a Kafka Streams application that goes through all the data in the topic and then exits?

Example. I create topic data based on date. The consumer gets the start of cron, runs through all the available data, and then .. does what? I do not want him to sit and wait for more data. Just guess it all and then exit gracefully.

Possible?

+4
source share
2 answers

You can create consumer, and then when it stops retrieving data, you can call consumer.close(). Or, if you want to conduct a survey again in the future, just call consumer.pause()and call .resumelater.

- . ,

data = consumer.poll()
if (!data.next()) {
   consumer.close()
}

, poll ConsumerRecord<K,V> Iterable.

+3

Kafka ( ), " ", , .

, "" Kafka Streams , (, ).

, bin/kafka-consumer-groups.sh, Streams ( ). Streams, kafka.admin.AdminClient .

+3

Source: https://habr.com/ru/post/1651845/


All Articles