Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Subscription get message by id json output #1704

Merged

Conversation

Nikolajls
Copy link
Contributor

@Nikolajls Nikolajls commented Jan 12, 2025

This change is to add a possiblity of JSON output from the subscription.get_message_by_id command.

Motivation

In our organization we suggested our teams to utilize Pulsarctl when investigating or debugging Pulsar topics, subscriotions.

Almost all of our messages are in the end json serialized data, but we have also had a few people utilize only strings as the data within the the byte[] sent to pulsar.

When an issue occurs in a consuming system, where e.g a message is received correctly, but fails to be proccesed in the system it always a guarentee that the consuming code allows the team to investigate the message data. That all depends on how they´ve set up their system.

However we advise to use Pulsarctl as a means to be able to view their messages, maybe copy the message content out to examine it further.

But currently the output of the command is a funky raw text outputted along with a hex.Dump of the []byte. looking like this:
image

In my example the message is very small, but lets say the message had like 50 fields with properties, maybe nested.
The column to the right becomes very big and hard to copy value from without doing some terminal magic and converting.

With this the change a JSON representation of the message - alongside the payload is outputted:
image
We can then copy the entire result (or pipe it to something else), unescape the escaped json from PayloadAsString property and have the JSON content available"

I know that messages can also be something entirely else like a file read from disk to a byte array - like a jpg sent as a byte[].

This with text output looks like this:
image

And with json output looks like this:
image

Modifications

Describe the modifications you've done.
Add readMessage struct
Add usage of WithObject output as wel.

Verifying this change

I have another PR #1699 for the same command fixing a typo.
And this issue #1703 for verifying needs some input.

  • Make sure that the change passes the CI checks.

(Please pick either of the following options)

This change is a trivial rework / code cleanup without any test coverage.

Documentation

Check the box below.

  • no-need-doc

Copy link

@Nikolajls:Thanks for your contribution. For this PR, do we need to update docs?
(The PR template contains info about doc, which helps others know more about the changes. Can you provide doc-related info in this and future PR descriptions? Thanks)

@github-actions github-actions bot added the doc-info-missing This pr needs to mark a document option in description label Jan 12, 2025
@Nikolajls Nikolajls changed the title fea:t: Subscription get message by id json output feat: Subscription get message by id json output Jan 12, 2025
@Nikolajls Nikolajls marked this pull request as ready for review January 12, 2025 20:27
Copy link

@Nikolajls:Thanks for providing doc info!

@github-actions github-actions bot added no-need-doc This pr does not need any document and removed doc-info-missing This pr needs to mark a document option in description labels Jan 13, 2025
@zymap zymap merged commit 6c42e3a into streamnative:master Jan 15, 2025
4 checks passed
zymap pushed a commit that referenced this pull request Jan 15, 2025
* Add an possible JSON output of the get message by id.

* rename readMessage struct to not export , modify string output

(cherry picked from commit 6c42e3a)
zymap pushed a commit that referenced this pull request Jan 15, 2025
* Add an possible JSON output of the get message by id.

* rename readMessage struct to not export , modify string output

(cherry picked from commit 6c42e3a)
zymap pushed a commit that referenced this pull request Jan 15, 2025
* Add an possible JSON output of the get message by id.

* rename readMessage struct to not export , modify string output

(cherry picked from commit 6c42e3a)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants