Interface Backend.EventLog

  • Enclosing class:
    Backend

    public static interface Backend.EventLog
    A strictly ordered log of submitted events.
    • 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, not null
        eventPayload - the payload representing the event, not null
      • 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), a EventIdNotFoundException 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 not null, only events after the event with the provided UUID will be considered.
        eventConsumer - a consumer that should receive all events, not null
        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