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

Allow byte[] keys for messages (#1016) #2612

Merged
merged 2 commits into from
Sep 27, 2018
Merged

Conversation

ivankelly
Copy link
Contributor

Sometimes it can be useful to send something more complex than a
string as the key of the message. However, early on Pulsar chose to
make String the only way to send a key, and this permeates throughout
the code, so we can't very well change it now.

This patch adds rudimentary byte[] key support. If a user adds a
byte[] key, the byte[] is base64 encoded and stored in the normal key
field. We also send a flag to denote that it is base64 encoded, so the
receiving end knows to decode it correctly. There's no schema or
anything attached to this. Any SerDe has to be handled manually by the
client.

Sometimes it can be useful to send something more complex than a
string as the key of the message. However, early on Pulsar chose to
make String the only way to send a key, and this permeates throughout
the code, so we can't very well change it now.

This patch adds rudamentary byte[] key support. If a user adds a
byte[] key, the byte[] is base64 encoded and stored in the normal key
field. We also send a flag to denote that it is base64 encoded, so the
receiving end knows to decode it correct. There's no schema or
anything attached to this. Any SerDe has to be handled manually by the
client.
@ivankelly ivankelly self-assigned this Sep 19, 2018
@ivankelly ivankelly added area/client type/enhancement The enhancements for the existing features or docs. e.g. reduce memory usage of the delayed messages labels Sep 19, 2018
*
* @param key routing key for message, in byte array form
*/
TypedMessageBuilder<T> keyBytes(byte[] key);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

any particular reason on naming this keyBytes instead of key?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

symmetry with the getKeyBytes() call on Message.

@sijie sijie mentioned this pull request Sep 19, 2018
@ivankelly
Copy link
Contributor Author

rerun integration tests
rerun java8 tests

@sijie
Copy link
Member

sijie commented Sep 21, 2018

run java8 tests

2 similar comments
@sijie
Copy link
Member

sijie commented Sep 24, 2018

run java8 tests

@sijie
Copy link
Member

sijie commented Sep 24, 2018

run java8 tests

@jiazhai
Copy link
Member

jiazhai commented Sep 27, 2018

rerun java8 tests

@sijie sijie added this to the 2.2.0 milestone Sep 27, 2018
@sijie sijie merged commit 30f6935 into apache:master Sep 27, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/client type/enhancement The enhancements for the existing features or docs. e.g. reduce memory usage of the delayed messages
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants