-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
Conversation
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.
* | ||
* @param key routing key for message, in byte array form | ||
*/ | ||
TypedMessageBuilder<T> keyBytes(byte[] key); |
There was a problem hiding this comment.
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
?
There was a problem hiding this comment.
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.
rerun integration tests |
run java8 tests |
2 similar comments
run java8 tests |
run java8 tests |
rerun java8 tests |
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.