简体   繁体   中英

How to temporarily resume Spring Kafka listener

I am maintaining a Spring Boot application that uses Spring Kafka for a variety of asynchronous flows. I have implemented functionality that allows for me to dynamically pause and resume any Kafka Listener / consumer of my choosing. However, I would like to be able to resume a listener / consumer in a way such that it only temporarily polls a specified fixed number of Kafka messages (eg 1 or 5) such that I can safely test the business logic of the listener before opening / resuming it completely. What would be a natural way of doing this?

The latest version (2.8) allows you to fetch individual (or a group) of messages using the KafkaTemplate instead of a message-driven approach.

https://docs.spring.io/spring-kafka/docs/current/reference/html/#kafka-template-receive

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM