Compatibility betweekn kafka-junit and Kafka-streams
See original GitHub issueI have developed a kafka-streams application and I’m using kafka-junit4 to test my application. With the SharedKafkaTestResource class I can use Kafka Consumer and Kafka Producer while my kafka streams app don’t link to the sharedKafkaTestResource.
Does sharedKafkaTestResource support KafkaStream?
What is the KafkaStream configuration to connect it to the in memory Kafka Cluster?
The following code snippet shows how I connect my kafkaStream to the SharedKafkaTestResource: ` @ClassRule public static final SharedKafkaTestResource sharedKafkaTestResource = new SharedKafkaTestResource();
final KafkaTestUtils kafkaTestUtils = getKafkaTestUtils(); kafkaTestUtils.createTopic(INPUT_TOPIC, 5, Short.valueOf(“1”)); kafkaTestUtils.createTopic(OUTPUT_TOPIC, 5, Short.valueOf(“1”));
Properties props = new Properties(); props.setProperty(StreamsConfig.APPLICATION_ID_CONFIG, “registryStreamProcessor”); props.setProperty(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG, sharedKafkaTestResource.getKafkaConnectString()); RegistryKafkaStream stream = new RegistryKafkaStream(props, INPUT_TOPIC, OUTPUT_TOPIC, Consumed.with(new AdapterMessageKeySerde(), new Serdes.StringSerde())); stream.start();`
Issue Analytics
- State:
- Created 5 years ago
- Comments:6
Top GitHub Comments
I added a test case to the code base. Check it out in this PR here: https://github.com/salesforce/kafka-junit/pull/21
I think the piece you’re missing is that stream processing is asynchronous. You start the stream processor and then immediately look for results, but don’t give it any time to do the actual processing.
Let me know if this helps
Thank’s, It’s working fine!