-
-
Notifications
You must be signed in to change notification settings - Fork 3
Description
Currently code uses directly org.apache.kafka.clients.producer.KafkaProducer and org.apache.kafka.clients.consumer.KafkaConsumer. Code should use org.apache.kafka.clients.producer.Producer and org.apache.kafka.clients.consumer.Consumer interfaces instead.
Why this matters? Because Kafka Java client library provides both MockConsumer and MockProducer out of the box which implement those interfaces. This allows one to use those mock implementations in place of the actual Kafka* versions when doing unit testing. Now however since code uses the Kafka* versions directly with type hints in function signature one gets a java.lang.ClassCastException when calling those functions with mock implementations.
One can go around this via proxy but that requires manual setup and creating your own mock implementations. Since Kafka Client library provides these out of the box they should be preferred.