MINOR: Add Protobuf message formatter for kafka-console-consumer - #23260
Open
ssbytedev wants to merge 1 commit into
Open
MINOR: Add Protobuf message formatter for kafka-console-consumer#23260ssbytedev wants to merge 1 commit into
ssbytedev wants to merge 1 commit into
Conversation
Adds ProtobufMessageFormatter implementing org.apache.kafka.common.MessageFormatter, matching KIP-1337: compiles .proto definitions from a user-specified proto.dir via protoc at configure() time, resolves the configured message.type, and decodes records with DynamicMessage, printing canonical ProtoJSON. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
|
A label of 'needs-attention' was automatically added to this PR in order to raise the |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implements KIP-1337 (currently Under Discussion) as a reference
implementation to make the proposal concrete for discussion.
What
Adds ProtobufMessageFormatter for kafka-console-consumer, implementing the existing
org.apache.kafka.common.MessageFormatter extension point.
Why
Allows inspecting Protobuf payloads from the console consumer using local .proto
schema files, without requiring a schema registry.
How
--formatter org.apache.kafka.tools.consumer.ProtobufMessageFormatter
--formatter-property proto.dir=/path/to/protos
--formatter-property message.type=com.example.MyEvent
At configure() time, compiles every *.proto file under proto.dir via protoc
(--descriptor_set_out, --include_imports), resolves the configured message.type
against the resulting descriptors, and caches both. At writeTo() time, decodes
each record with DynamicMessage.parseFrom and prints canonical ProtoJSON via
protobuf-java-util JsonFormat. Requires protoc on PATH.
Testing
found, invalid .proto syntax, message.type not found, malformed record bytes,
null (tombstone) and empty-value records - compiling real .proto sources via
protoc, not synthetic descriptors
without --skip-message-on-error, tombstone)
Open questions from the KIP not yet resolved here
via protoc --proto_path but not exercised by a dedicated test yet
placeholder pending KIP agreement