Skip to content

Need a more obvious way to set event time in a message #856

@anguillanneuf

Description

@anguillanneuf

EventTime is useful in deciding when to advance high watermarks for streaming engines (Beam/Spark/Flink). Right now to set event time in a message published to Pub/Sub Lite, one needs to use a custom attribute of key "x-goog-pubsublite-event-time-timestamp-proto" and pass in a string using MessageTransforms.encodeAttributeEventTime():

import com.google.cloud.pubsublite.cloudpubsub.MessageTransforms;

// ..

    String eventTime = MessageTransforms
        .encodeAttributeEventTime(Timestamp.newBuilder().setSeconds(100).build());

    ByteString data = ByteString.copyFromUtf8(message);

    PubsubMessage pubsubMessage =
        PubsubMessage.newBuilder()
            .setData(data)
            .putAttributes("x-goog-pubsublite-event-time-timestamp-proto", eventTime)
            .build();

    ApiFuture<String> future = publisher.publish(pubsubMessage);

Is there a better way to surface EventTime from the protos?

* <pre>
* An optional, user-specified event time.
* </pre>
*
* <code>.google.protobuf.Timestamp event_time = 4;</code>
*
* @return Whether the eventTime field is set.
*/
boolean hasEventTime();
/**
*
*
* <pre>
* An optional, user-specified event time.
* </pre>
*
* <code>.google.protobuf.Timestamp event_time = 4;</code>
*
* @return The eventTime.
*/
com.google.protobuf.Timestamp getEventTime();
/**
*
*
* <pre>
* An optional, user-specified event time.
* </pre>
*
* <code>.google.protobuf.Timestamp event_time = 4;</code>
*/
com.google.protobuf.TimestampOrBuilder getEventTimeOrBuilder();

Metadata

Metadata

Assignees

No one assigned

    Labels

    api: pubsubliteIssues related to the googleapis/java-pubsublite API.priority: p2Moderately-important priority. Fix may not be included in next release.triage meI really want to be triaged.type: feature request‘Nice-to-have’ improvement, new feature or different behavior or design.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions