Testing KStream.through operation behaviour
This is small app demonstrating behaviour of streaming application when KStream.through operation is used and target topic is used by another streaming application or producer.
There are three components:
InputProducer - produces random messages and writes them into topic called input-topic
StreamingApp - streaming application that uses input-topic as source, transforms the message, writes it to topic called "side-topic", then writes the message to system output, and finally writes it to topic called output-topic
IntermediateProducer - this is the "bad guy". It writes messages directly to side-topic causing unexpected behavior of StreamingApp component
Zookeeper and Kafka servers installed and ready for use
Topics created: "input-topic", "side-topic", "output-topic"
Start InputProducer and let it run
Start StreamingApp and observe it's output. You should something like this:
Message after through: MESSAGE NO 1 PRODUCED AT 14:20:40.990
Message read from input topic: Message no 1 produced at 14:20:41.091
Stop InputProducer and wait until StreamingApp's output stops (this means streaming app consumed all messages InputProducer produced).
Start IntermediateProducer and observe StreamingApp's output again.
You will notice something like this:
Message after through: This message is not from input-topic. 14:27:03.898
Message after through: This message is not from input-topic. 14:27:03.999
Message after through: This message is not from input-topic. 14:27:04.099