Skip to content

Instantly share code, notes, and snippets.

@nfo
nfo / RoutingTopology.java
Last active April 26, 2017 10:20
Kafka Streams: Calling series `KStream.branch()` to route records to n topics
KStream<Key, Value>[] branches = stream.branch((k, v) -> v.getType().equals("abc"));
branches[0].to(keySerde, valueSerde, "topic-abc");
branches = branches[1].branch((k, v) -> v.getType().equals("def"));
branches[0].to(keySerde, valueSerde, "topic-def");
branches = branches[1].branch((k, v) -> v.getType().equals("ghi"));
branches[0].to(keySerde, valueSerde, "topic-ghi");
// ....
@nfo
nfo / stderr
Created March 6, 2017 17:30
Kafka Streams - Stopped on stopped broker
Exception in thread "StreamThread-1" org.apache.kafka.streams.errors.StreamsException: Exception caught in process. taskId=0_23, processor=KSTREAM-SOURCE-0000000000, topic=abc, partition=23, offset=388592
at org.apache.kafka.streams.processor.internals.StreamTask.process(StreamTask.java:216)
at org.apache.kafka.streams.processor.internals.StreamThread.runLoop(StreamThread.java:641)
at org.apache.kafka.streams.processor.internals.StreamThread.run(StreamThread.java:368)
Caused by: org.apache.kafka.streams.errors.StreamsException: task [0_23] exception caught when producing
at org.apache.kafka.streams.processor.internals.RecordCollectorImpl.checkForException(RecordCollectorImpl.java:119)
at org.apache.kafka.streams.processor.internals.RecordCollectorImpl.send(RecordCollectorImpl.java:76)
at org.apache.kafka.streams.processor.internals.SinkNode.process(SinkNode.java:79)
at org.apache.kafka.streams.processor.internals.ProcessorContextImpl.forward(ProcessorContextImpl.java:83)
at org.apache.kafka.streams.ks