Kafka Unit Testing Transaction with MockProducer and MockConsumer

Viewed 219

Kafka now supports atomic consume/transform/produce operation via producer transaction as you can see below. Is there a way to unit test this logic? There is a MockConsumer and MockProducer that allow testing I/O operations toward consumer and producers as a unit tests however mocked classes are completely independent of one another. The logic below requires consumer group coordinator support. Is there a way to test logic below as a unit test using mocks and not as an integration test?

 producer.beginTransaction()
 while(true){ 
   consumer.poll()
 }
 producer.sendOffsetsToTransaction(consumerOffsets, consumerGroupId)
 producer.commitTransaction()
0 Answers
Related