devinbost opened a new pull request #7704:
URL: https://github.com/apache/pulsar/pull/7704
### Motivation
The current options for producing messages via the pulsar-client producer do
not easily allow the publishing of JSON objects. The default separator (a
comma) splits the JSON object into malformed parts when more than one key/value
pair is provided. It is possible to change the default separator to a substring
that is unlikely to be found, but for large messages, there is no guarantee
that the substring won't exist in the message. Moreover, for new users who
might not be aware that they can change the default separator, it can be
difficult and confusing for them when they have trouble determining how to
publish the JSON object. Publishing a JSON object is very common, so this
feature is much needed.
*Explain here the context, and why you're making that change. What is the
problem you're trying to solve.*
### Modifications
I added an additional parameter to allow passing the JSON object as a
string. I considered adding support for passing multiple JSON objects, but that
gets more complex to implement and may be unnecessary because most users can
either create a script with multiple lines with inline JSON messages to produce
repeatedly, or they can add an object splitter function or producer/consumer to
split an array of JSON objects into single JSON objects for a downstream
consumer. I chose to add the additional parameter (--json or -j) instead of
modifying the existing contract for passing messages (via --message or -m) to
ensure backwards compatability.
### Verifying this change
I ran into an environment-specific build issue that requires a dependency to
be added to my repo mirror, so I was unable to run tests locally and wanted to
get the PR created to get feedback on the approach before going further.
I also didn't see any unit tests for producing messages via the CLI, so I'd
like guidance on how that should be approached or if these changes are trivial
enough that they don't require testing.
### Does this pull request potentially affect one of the following parts:
*If `yes` was chosen, please highlight the changes*
- Dependencies: (no)
- The public API: (no)
- The schema: (no)
- The default values of configurations: (no)
- The wire protocol: (no)
- The rest endpoints: (no)
- **The admin cli options: (yes)**
- Anything that affects deployment: (don't know)
### Documentation
- Does this pull request introduce a new feature? **(yes)**
- If yes, how is the feature documented?
I updated documentation in a couple of places to document the new feature,
but I may have missed some places, so feedback on what other pages need to be
updated would be helpful.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]