Search code examples
javaapache-kafkaapache-kafka-streams

Kafka Streams DSL foreach vs process


I'm implementing the logic for rebuilding a file paginated to several kafka messages with the same key. Every time a page is received its content is appended to the corresponding file in a shared volume and, once the last page is appended, the topology has to include some extra processing steps.

  1. Should this be done with forEach or with process?
  2. Both forEach and process have void type, how can then be added the final extra steps to the topology?

Solution

  • Both accomplish the same goal. foreach is a terminal action of the DSL, however

    process method of the Processor API "returns" data to next Processors by forwarding it to the Context, as answered in your last question, not via the process method itself