Junior — Middle
Do you have experience working with Kafka Streams for stream data processing?
sobes.tech AI
Answer from AI
Yes, I have worked with Kafka Streams for stream data processing. Kafka Streams is a library for building applications and microservices that process data in real-time using Kafka topics.
Example of simple Kafka Streams usage in Java:
Properties props = new Properties();
props.put(StreamsConfig.APPLICATION_ID_CONFIG, "my-stream-app");
props.put(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG, "localhost:9092");
StreamsBuilder builder = new StreamsBuilder();
KStream<String, String> source = builder.stream("input-topic");
KStream<String, String> uppercased = source.mapValues(value -> value.toUpperCase());
uppercased.to("output-topic");
KafkaStreams streams = new KafkaStreams(builder.build(), props);
streams.start();
In this example, data from the "input-topic" is transformed to uppercase and written to "output-topic". Kafka Streams makes it easy to create such processing pipelines with support for scalability and fault tolerance.