Skip to content

Instantly share code, notes, and snippets.

@robvadai
Last active October 20, 2017 20:27
Show Gist options
  • Save robvadai/b2dfa6f332276209818f7c7ae77f98c4 to your computer and use it in GitHub Desktop.
Save robvadai/b2dfa6f332276209818f7c7ae77f98c4 to your computer and use it in GitHub Desktop.
Simple Kafka Streams data pipeline
streamBuilder
.stream(
STRING_SERDE, STRING_SERDE, upstreamTopicName
).filter((messageKey, messageBody) -> {
try {
Double.parseDouble(messageBody);
return true;
} catch (Throwable e) {
return false;
}
}
).map((messageKey, messageBody) -> {
BigDecimal numericMessage = new BigDecimal(messageBody);
Temperature temperature = Temperature.apply(numericMessage);
return new KeyValue<>(messageKey, temperature);
}).to(STRING_SERDE, avroSerde, downstreamTopicName);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment