Interface PersistentStreamContextCustomizer

All Superinterfaces:
Function<ProcessingContext,ProcessingContext>
Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@Internal @FunctionalInterface public interface PersistentStreamContextCustomizer extends Function<ProcessingContext,ProcessingContext>
Places resources on the ProcessingContext that a PersistentStreamConnection spans over a batch of events, returning the context the events of that batch are consumed with.

Invoked exactly once per batch, so it carries resources that are constant for every event a connection delivers, rather than per-event information such as the TrackingToken.

Returning the context lets an implementation branch off the one it is given, through ProcessingContext.withResource(org.axonframework.messaging.core.Context.ResourceKey, Object).

Implementations must be thread-safe: the batches of the segments of one stream are processed concurrently, so the same customizer is invoked from several threads, each with its own ProcessingContext.

Marked Internal, because it is intended as an internal extension point not a general-purpose interception point. Use a MessageHandlerInterceptor to influence event handling.

Since:
5.3.0
Author:
Jakob Hatzl
See Also:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    A PersistentStreamContextCustomizer placing no resources on the ProcessingContext, handing back the context it was given, used when a connection needs no batch-level resources of its own.
  • Method Summary

    Modifier and Type
    Method
    Description
    apply(ProcessingContext processingContext)
    Places resources on the given processingContext, which spans a single batch of events, and returns the context the events of that batch are consumed with.

    Methods inherited from interface java.util.function.Function

    andThen, compose
  • Field Details

    • NO_OP

      A PersistentStreamContextCustomizer placing no resources on the ProcessingContext, handing back the context it was given, used when a connection needs no batch-level resources of its own.
  • Method Details

    • apply

      ProcessingContext apply(ProcessingContext processingContext)
      Places resources on the given processingContext, which spans a single batch of events, and returns the context the events of that batch are consumed with.
      Specified by:
      apply in interface Function<ProcessingContext,ProcessingContext>
      Parameters:
      processingContext - the batch-scoped processing context to place resources on
      Returns:
      the context to consume the batch with, either the given processingContext or one branched off it