-
Notifications
You must be signed in to change notification settings - Fork 3.6k
PIP 5: Event time
Sijie Guo edited this page Jul 26, 2018
·
5 revisions
- Status: Implemented in 1.20
- Author: Sijie Guo
- Discussion Thread: https://lists.apache.org/thread.html/7270626fcd5b0ffd486c45ab32deda48359c5bc3cca2082ca2d99bce@%3Cdev.pulsar.apache.org%3E
- Issue: #732
In use cases such as streaming processing, they need a timestamp in messages to process. This timestamp is called event time
,
which is different from publish time
- the timestamp that this even occurs. The event time
is typically provided and set
by the applications.
To solve these use cases, we propose to add a event time
for pulsar messages.
- add a method
#setEventTime(long timestamp)
inMessageBuilder.java
/**
* Set the event time for a given message.
* <p> Applications can retrieve the event time by calling `Message#getEventTime()`.
* This field is useful for stream processing.
* <p> Note: currently pulsar doesn't support event-time based index. so the subscribers can't
* seek the messages by event time.
*/
MessageBuilder setEventTime(long timestamp);
- add a method
#getEventTime()
inMessage.java
/**
* Get the event time associated with this event. It is typically set by the applications.
* <p>If there isn't any event time associated with this event, it will return `-1`.
*/
long getEventTime();
we propose to introduce an optional field called event_time
in MessageMetadata
.
message MessageMetadata {
...
// the timestamp that this event occurs. it is typically set by applications.
// if this field is omitted, `publish_time` can be used for the purpose of `event_time`.
optional int32 event_time = 12 [default = -1];
}
This change is backward compatible. There is no special migration plan required.
This proposal doesn't cover following areas:
- we don't provide any event time index. that means we can't rewind based on event time.