Class RecursivePublicationGuard
java.lang.Object
io.fluxzero.sdk.publishing.RecursivePublicationGuard
- All Implemented Interfaces:
DispatchInterceptor
Prevents runaway recursive publication loops by carrying a publication depth in message metadata.
-
Field Summary
FieldsFields inherited from interface DispatchInterceptor
defaultInterceptors, noOp -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioninterceptDispatch(Message message, MessageType messageType, String topic) Intercepts the dispatch of a message before it is serialized and published or locally handled.protected intnextDepth(MessageType messageType) protected intparseDepth(String value) protected intMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface DispatchInterceptor
andThen, modifySerializedMessage, monitorDispatch
-
Field Details
-
PUBLICATION_DEPTH_METADATA_KEY
- See Also:
-
DEFAULT_MAX_DEPTH
public static final int DEFAULT_MAX_DEPTH- See Also:
-
-
Constructor Details
-
RecursivePublicationGuard
public RecursivePublicationGuard() -
RecursivePublicationGuard
public RecursivePublicationGuard(int maxPublicationDepth)
-
-
Method Details
-
interceptDispatch
Description copied from interface:DispatchInterceptorIntercepts the dispatch of a message before it is serialized and published or locally handled.You may modify the message or return
nullto block dispatching. Throwing an exception also prevents dispatching.- Specified by:
interceptDispatchin interfaceDispatchInterceptor- Parameters:
message- the message to be dispatchedmessageType- the type of the message (e.g., COMMAND, EVENT, etc.)topic- the target topic or null if not applicable- Returns:
- the modified message, the same message, or
nullto prevent dispatch
-
nextDepth
-
readDepth
-
parseDepth
-