Interface EventAppender

All Superinterfaces:
DescribableComponent
All Known Implementing Classes:
ProcessingContextEventAppender

public interface EventAppender extends DescribableComponent
Component that appends events to an EventSink in the context of a ProcessingContext. This makes the EventAppender the preferred way to append events from within another message handling method.

The events will be appended in the context this appender was created for. You can construct one through the forContext(ProcessingContext).

When using annotation-based @MessageHandler-methods and you have declared an argument of type EventAppender, the appender will automatically be injected by the EventAppenderParameterResolverFactory.

As this component is ProcessingContext-scoped, it is not retrievable from the Configuration.

Since:
5.0.0
Author:
Mitchell Herrijgers
  • Field Details

  • Method Details

    • forContext

      static EventAppender forContext(ProcessingContext context)
      Creates an appender for the given ProcessingContext.

      You can use this appender only for the context it was created for. There is no harm in using this method more than once, as the same appender will be returned.

      Parameters:
      context - The ProcessingContext to create the appender for.
      Returns:
      The created appender.
    • forContext

      static EventAppender forContext(ProcessingContext context, EventSink eventSink, MessageTypeResolver messageTypeResolver)
      Creates an appender for the given ProcessingContext and EventSink. You can use this appender only for the context it was created for. There is no harm in using this method more than once, as the same appender will be returned.
      Parameters:
      context - The ProcessingContext to create the appender for.
      eventSink - The EventSink to use for the appender.
      messageTypeResolver - The MessageTypeResolver to use for the appender.
      Returns:
      The created appender.
    • append

      default void append(Object... events)
      Append a collection of events to the event store in the current ProcessingContext. The events will be published when the context commits.
      Parameters:
      events - The collection of events to publish.
    • append

      void append(List<?> events)
      Append a collection of events to the event store in the current ProcessingContext. The events will be published when the context commits.
      Parameters:
      events - The collection of events to publish.
    • append

      void append(List<?> events, Metadata metadata)
      Append a collection of events to the event store in the current ProcessingContext, all with the given Metadata. If an event is already a Message, the provided metadata is merged with its existing metadata (provided values take precedence on conflict).
      Parameters:
      events - The collection of events to publish.
      metadata - The metadata to attach to every event.
    • append

      default void append(Object event, Metadata metadata)
      Append a single event to the event store in the current ProcessingContext with the given Metadata. If the event is already a Message, the provided metadata is merged with its existing metadata (provided values take precedence on conflict).
      Parameters:
      event - The event to publish.
      metadata - The metadata to attach to the event.