Class RecursivePublicationGuard

java.lang.Object
io.fluxzero.sdk.publishing.RecursivePublicationGuard
All Implemented Interfaces:
DispatchInterceptor

public class RecursivePublicationGuard extends Object implements DispatchInterceptor
Prevents runaway recursive publication loops by carrying a publication depth in message metadata.
  • Field Details

  • Constructor Details

    • RecursivePublicationGuard

      public RecursivePublicationGuard()
    • RecursivePublicationGuard

      public RecursivePublicationGuard(int maxPublicationDepth)
  • Method Details

    • interceptDispatch

      public Message interceptDispatch(Message message, MessageType messageType, String topic)
      Description copied from interface: DispatchInterceptor
      Intercepts the dispatch of a message before it is serialized and published or locally handled.

      You may modify the message or return null to block dispatching. Throwing an exception also prevents dispatching.

      Specified by:
      interceptDispatch in interface DispatchInterceptor
      Parameters:
      message - the message to be dispatched
      messageType - 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 null to prevent dispatch
    • nextDepth

      protected int nextDepth(MessageType messageType)
    • readDepth

      protected int readDepth(Metadata metadata)
    • parseDepth

      protected int parseDepth(String value)