-
Notifications
You must be signed in to change notification settings - Fork 24
samples: add event time as a custom attribute #863
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
Conversation
samples/snippets/src/main/java/pubsublite/PublishWithCustomAttributesExample.java
Outdated
Show resolved
Hide resolved
| System.out.println("Data : " + message.getData().toStringUtf8()); | ||
| System.out.println("Ordering key : " + message.getOrderingKey()); | ||
| System.out.println("Attributes : "); | ||
| message |
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.
I'd also demonstrate extracting the event time
MessageTransforms. decodeAttributeEventTime(message.getAttributesMap().get(MessageTransforms.PUBSUB_LITE_EVENT_TIME_TIMESTAMP_PROTO))
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.
This is a generic SubscriberExample for messages with and without attributes.
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.
Ah okay. Thats fine then. Could you add:
if (message.getAttributesMap().containsKey(MessageTransforms.PUBSUB_LITE_EVENT_TIME_TIMESTAMP_PROTO)) {
System.out.println("Event timestamp : ", + MessageTransforms. decodeAttributeEventTime(message.getAttributesMap().get(MessageTransforms.PUBSUB_LITE_EVENT_TIME_TIMESTAMP_PROTO)));
}
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.
Yep, a if..else exists in the last commit.
2a26631 to
b3b55f0
Compare
Fixes #856
Show the proper way to publish a message to Pub/Sub Lite with an event time as an attribute.