Package io.mats3.api.intercept
Interface MatsStageInterceptor
- All Known Subinterfaces:
MatsStageInterceptor.MatsStageInterceptOutgoingMessages
- All Known Implementing Classes:
LocalStatsMatsInterceptor
,MatsMetricsLoggingInterceptor
,MatsMicrometerInterceptor
public interface MatsStageInterceptor
Implement this interface to intercept Stage Processing, then register with
MatsInterceptable.addStageInterceptor(MatsStageInterceptor)
.
Intercepts stage processors with ability to modify the stage processing, and implement extra logging and metrics
gathering.-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interface
While still within the stage process context, this interception enables modifying outgoing messages from the user lambda, setting trace properties, adding "sideloads", deleting a message, or initiating additional messages.static interface
Enables the intercepting of the invocation of the "user lambda" in a Stage, with ability to wrap theMatsEndpoint.ProcessContext
(and thus modify any reply, request, next or initiations) and/or modifying state and message - or even take over the entire stage.static interface
Common context elements for stage interception, including all the incoming message/envelope data and metadata.static interface
static interface
static interface
static interface
static interface
static interface
-
Method Summary
Modifier and TypeMethodDescriptiondefault void
Invoked after the stage is fully completed, outgoing messages sent, db and messaging system committed.default void
Special variant ofstageCompleted(StageCompletedContext)
which is invoked when aMatsEndpoint.ProcessContext.nextDirect(Object)
has been performed: As opposed to the ordinary variant, this does not execute outside the stage's transactional demarcation, since the nextDirect stage processing happens within the same transactional demarcation as the stage which invoked nextDirect.default void
stagePreprocessAndDeserializeError
(MatsStageInterceptor.StagePreprocessAndDeserializeErrorContext context) Invoked if any of the preprocessing and deserialization activities on the incoming message from the message system fails, and hence no Stage processing will be performed - i.e., no further methods of the interceptor will be invoked.default void
Invoked right after message have been received, preprocessed and deserialized, before invoking the user lambda.
-
Method Details
-
stagePreprocessAndDeserializeError
default void stagePreprocessAndDeserializeError(MatsStageInterceptor.StagePreprocessAndDeserializeErrorContext context) Invoked if any of the preprocessing and deserialization activities on the incoming message from the message system fails, and hence no Stage processing will be performed - i.e., no further methods of the interceptor will be invoked. Conversely, this method will not be invoked in normal situations: If the normal user lambda throws, or database or messaging system fails, this will result in theMatsStageInterceptor.StageCompletedContext
of thestageCompleted(..)
call describe the problem and contain the cause, seeMatsStageInterceptor.StageCompletedContext.ProcessResult.USER_EXCEPTION
andMatsStageInterceptor.StageCompletedContext.ProcessResult.SYSTEM_EXCEPTION
. Note: This should really never be triggered. It would be prudent to "notify the humans" if it ever did. -
stageReceived
Invoked right after message have been received, preprocessed and deserialized, before invoking the user lambda. (If any error occurs during preprocess or deserialization, thenstagePreprocessAndDeserializeError(StagePreprocessAndDeserializeErrorContext)
is invoked instead). -
stageCompleted
Invoked after the stage is fully completed, outgoing messages sent, db and messaging system committed. You cannot anymore modify any outgoing messages etc - for this, implementMatsStageInterceptor.MatsStageInterceptOutgoingMessages
. -
stageCompletedNextDirect
Special variant ofstageCompleted(StageCompletedContext)
which is invoked when aMatsEndpoint.ProcessContext.nextDirect(Object)
has been performed: As opposed to the ordinary variant, this does not execute outside the stage's transactional demarcation, since the nextDirect stage processing happens within the same transactional demarcation as the stage which invoked nextDirect. Therefore, no outgoing messages has yet been sent, and db and message system are not yet committed.
-