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(@Nonnull 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(@Nonnull ProcessingContext context, @Nonnull EventSink eventSink, @Nonnull 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(@Nonnull 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.