Status
Current state: Under Discussion
Discussion thread:
JIRA: here
Please keep the discussion on the mailing list rather than commenting on the wiki (wiki discussions get unwieldy fast).
Motivation
As for now, KStream#print
leads to a predefined output where key
and value
are printed with comma separation.
KAFKA-4830 suggests to extend print
in a way that it takes KeyValueMapper
as a parameter.
This will allow a user to change outputs according to the users demand.
Public Interfaces
The affected interface is KStream
, which needs to be extended with another overloaded version of print
:
void print(final Serde<K> keySerde,
final Serde<V> valSerde,
final String streamName,
final KeyValueMapper<K, V, String> mapper);
Proposed Changes
See pull request GH-2669.
This PR contains a discussion regarding KAFKA-4830 as well as KAFKA-4772.
Compatibility, Deprecation, and Migration Plan
The extension of print
will not introduce compatibility issues – we can maintain the current output by keeping the current output format as a default (if mapper was not set):
if(mapper == null) {
printStream.println("[" + streamName + "]: " + keyToPrint + " , " + valueToPrint);
} else {
printStream.println("[" + streamName + "]: " + mapper.apply(keyToPrint, valueToPrint));
}