Interface EventSink

All Superinterfaces:
DescribableComponent
All Known Subinterfaces:
EventBus, EventStore
All Known Implementing Classes:
DelegatingEventBus, InterceptingEventBus, InterceptingEventSink, InterceptingEventStore, RecordingEventBus, RecordingEventSink, RecordingEventStore, SimpleEventBus, StorageEngineBackedEventStore

public interface EventSink extends DescribableComponent
Interface describing the option to publish events.

When a ProcessingContext is provided, the publication is typically staged in the post invocation phase of the ProcessingContext. As a consequence, the result of publication will be made apparent in the ProcessingContext. When providing no ProcessingContext, the result of publication is carried in the resulting CompletableFuture.

Since:
5.0.0
Author:
Allard Buijze, Steven van Beelen
  • Method Details

    • publish

      default CompletableFuture<Void> publish(@Nullable ProcessingContext context, EventMessage... events)
      Publishes the given events within the given context, when present.

      When present, the post invocation phase is used to publish the events. As a consequence, the resulting CompletableFuture completes when the events are staged in that phase.

      When no ProcessingContext is provided, implementers of this interface may choose to create a ProcessingContext when necessary.

      Parameters:
      context - The processing context, if any, to publish the given events in.
      events - The events to publish in this sink.
      Returns:
      A CompletableFuture of Void. When this completes and a non-null context was given, this means the events have been successfully staged. When a null context was provided, successful completion of this future means the events where published.
    • publish

      CompletableFuture<Void> publish(@Nullable ProcessingContext context, @Nonnull List<EventMessage> events)
      Publishes the given events within the given context, when present.

      When present, the post invocation phase is used to publish the events. As a consequence, the resulting CompletableFuture completes when the events are staged in that phase.

      When no ProcessingContext is provided, implementers of this interface may choose to create a ProcessingContext when necessary.

      Parameters:
      context - The processing context, if any, to publish the given events in.
      events - The events to publish in this sink.
      Returns:
      A CompletableFuture of Void. When this completes and a non-null context was given, this means the events have been successfully staged. When a null context was provided, successful completion of this future means the events where published.