forked from apache/pulsar
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[tools] Pulsar Client: add ability to produce KV messages (apache#11303)
### Motivation Currently (Pulsar 2.8.0) it is not easy to produce messages with KeyValue encoding, because command line tools do not provide such support. With this change the user will be able to set the schema while using `pulsar-client produce` We are adding three parameters: * "--key-schema" : this is the schema for the Key (default :"string") * "--value-schema": this is the schema for the Value (default: "bytes") * "--key-value-encoding-type": this is the type of encoding with values: none,separated,inline with key-value-encoding-type=node (default behaviour) we are not using KV encoding The command is 100% compatible with previous versions ### Modifications Add support for the properties listed above. We are using "Schema.AUTO_PRODUCE_BYTES" in order to deal with the Schema registry. The user will pass the raw value as message and we are passing it without modifications to Pulsar. Example command to send a KV message with JSON key and value: `bin/pulsar-client produce --key-value-encoding-type separated -k '{"a":"b"}' -m '{"a":"b"}' --key-schema 'json:{"type": "record","namespace": "com.example","name": "FullName", "fields": [{ "name": "a", "type": "string" }]} ' --value-schema 'json:{"type": "record","namespace": "com.example","name": "FullName", "fields": [{ "name": "a", "type": "string" }]} ' test` for AVRO and JSON the schema is written inline after the prefix "avro:" and "json:" ### Verifying this change This change added unit tests
- Loading branch information
Showing
2 changed files
with
133 additions
and
10 deletions.
There are no files selected for viewing
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
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