com.vaadin.collaborationengine.
Interface Backend.EventLog
-
Enclosing class:
public static interface Backend.EventLog
A strictly ordered log of submitted events.
-
-
Method Summary
All Methods Modifier and Type Method Description void
submitEvent(UUID trackingId, String eventPayload)
Submits an event through the backend to all subscribers.
Registration
subscribe(UUID newerThan, BiConsumer<UUID,String> eventConsumer)
Adds a subscriber to receive all past and future events for this event log.
void
truncate(UUID olderThan)
Removes all events in the log before the given id.
-
-
-
Method Detail
-
submitEvent
void submitEvent(UUID trackingId, String eventPayload)
Submits an event through the backend to all subscribers. The tracking id needs to be delivered to active subscribers but it is not necessary to preserve it for replaying old events to new subscribers.
Parameters:
trackingId
- the tracking id of this event, notnull
eventPayload
- the payload representing the event, notnull
-
subscribe
Registration subscribe(UUID newerThan, BiConsumer<UUID,String> eventConsumer) throws Backend.EventIdNotFoundException
Adds a subscriber to receive all past and future events for this event log. A newly added subscriber should initially receive all previous events in the log based on their original order so that it can catch up with the latest state. New events should be delivered (in order) only after all previous events have been delivered. It is not allowed to invoke the consumer again until the previous invocation has returned.
If the provided
newerThan
ID is not null and is not found in the event log (perhaps due to truncation), aEventIdNotFoundException
should be thrown. When the exception is caught by the code calling this method, it may want to re-attempt the subscription with another ID. A Collaboration Engine topic, for example, will try to load the latest snapshot and subscribe from the ID associated with it.Parameters:
newerThan
- if notnull
, only events after the event with the provided UUID will be considered.eventConsumer
- a consumer that should receive all events, notnull
Returns:
a registration to remove the event consumer, not
null
Throws:
Backend.EventIdNotFoundException
- when the provided UUID does not exist in the event log.
-
truncate
void truncate(UUID olderThan)
Removes all events in the log before the given id. If a
null
id is passed, then all events are removed.Parameters:
olderThan
- the oldest UUID to retain
-
-