How to process a KStream in a batch of max size or fallback to a time window?

后端 未结 2 2018
长情又很酷
长情又很酷 2020-12-21 14:38

I would like to create a Kafka stream-based application that processes a topic and takes messages in batches of size X (i.e. 50) but if the stream has low flow, to give me w

2条回答
  •  天涯浪人
    2020-12-21 15:05

    The simplest way might be, to use a stateful transform() operation. Each time you receive a record, you put it into the store. When you have received 50 records, you do your processing, emit output, and delete the records from the store.

    To enforce processing if you don't read the limit in a certain amount of time, you can register a wall-clock punctuation.

提交回复
热议问题