Last active
October 20, 2017 20:27
-
-
Save robvadai/b2dfa6f332276209818f7c7ae77f98c4 to your computer and use it in GitHub Desktop.
Simple Kafka Streams data pipeline
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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