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
FieldsModifier and TypeFieldDescriptionstatic final PersistentStreamContextCustomizerAPersistentStreamContextCustomizerplacing no resources on theProcessingContext, handing back the context it was given, used when a connection needs no batch-level resources of its own. -
Method Summary
Modifier and TypeMethodDescriptionapply(ProcessingContext processingContext) Places resources on the givenprocessingContext, which spans a single batch of events, and returns the context the events of that batch are consumed with.
-
Field Details
-
NO_OP
APersistentStreamContextCustomizerplacing no resources on theProcessingContext, handing back the context it was given, used when a connection needs no batch-level resources of its own.
-
-
Method Details
-
apply
Places resources on the givenprocessingContext, which spans a single batch of events, and returns the context the events of that batch are consumed with.- Specified by:
applyin interfaceFunction<ProcessingContext,ProcessingContext> - Parameters:
processingContext- the batch-scoped processing context to place resources on- Returns:
- the context to consume the batch with, either the given
processingContextor one branched off it
-