Class AbstractDuplexHandler
- All Implemented Interfaces:
Handler,InboundHandler,OutboundHandler
- Direct Known Subclasses:
ConnectionHealthHandler,ConnectionReconnectHandler
InboundHandler and OutboundHandler
interfaces to handle bidirectional message flow in a Pipeline.
Subclasses can override one or both sets of handler methods to implement custom logic for inbound and outbound processing. This class is useful for handlers that need to observe or manipulate both directions of message flow.
The default implementations of all methods simply propagate events through the pipeline without any additional processing, making this class suitable as a base for handlers that only need to override specific methods.
- Since:
- 1.0.0
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract org.slf4j.LoggerReturns the logger of the subclass.voidhandleInboundFailure(Context ctx, Throwable cause) Invoked when an error occurs during the processing of an inbound message.voidhandleInboundMessage(Context ctx, InboundMessage msg) Invoked when an inbound message is received and propagated through the pipeline.voidhandleOutboundMessage(Context ctx, OutboundMessage msg, CompletableFuture<Void> future) Invoked when an outbound message is propagated through the pipeline.voidhandleUserEvent(Context ctx, Object evt) Invoked when a user-defined event is propagated through the pipeline.voidInvoked when the connection associated with this context becomes active.voidInvoked when the connection associated with this context becomes inactive.voidonHandlerAdded(Context ctx) Invoked when this handler is added to the pipeline.voidonHandlerRemoved(Context ctx) Invoked just before this handler is removed from the pipeline.
-
Constructor Details
-
AbstractDuplexHandler
public AbstractDuplexHandler()
-
-
Method Details
-
handleInboundFailure
Description copied from interface:InboundHandlerInvoked when an error occurs during the processing of an inbound message.This method can be used to log, transform, or recover from the error as appropriate.
- Specified by:
handleInboundFailurein interfaceInboundHandler- Parameters:
ctx- theContextthis handler is bound to.cause- theThrowabledescribing the failure.
-
handleInboundMessage
Description copied from interface:InboundHandlerInvoked when an inbound message is received and propagated through the pipeline.Handlers may inspect, transform, or act upon the message before forwarding it downstream.
- Specified by:
handleInboundMessagein interfaceInboundHandler- Parameters:
ctx- theContextthis handler is bound to.msg- theInboundMessagebeing processed.
-
handleOutboundMessage
Description copied from interface:OutboundHandlerInvoked when an outbound message is propagated through the pipeline.This method is responsible for handling or forwarding the outbound
OutboundMessage. Completion of the providedCompletableFuturesignals the success or failure of the operation.- Specified by:
handleOutboundMessagein interfaceOutboundHandler- Parameters:
ctx- theContextthis handler is bound to.msg- the outbound message to process.future- the future to complete once the message has been handled or an error has occurred.
-
handleUserEvent
Description copied from interface:HandlerInvoked when a user-defined event is propagated through the pipeline.Handlers can choose to react to or forward the event, depending on their logic.
- Specified by:
handleUserEventin interfaceHandler- Parameters:
ctx- theContextthis handler is bound to.evt- the user-defined event to handle.
-
onConnectionActive
Description copied from interface:HandlerInvoked when the connection associated with this context becomes active.- Specified by:
onConnectionActivein interfaceHandler- Parameters:
ctx- theContextthis handler is bound to.
-
onConnectionInactive
Description copied from interface:HandlerInvoked when the connection associated with this context becomes inactive.- Specified by:
onConnectionInactivein interfaceHandler- Parameters:
ctx- theContextthis handler is bound to.
-
onHandlerAdded
Description copied from interface:HandlerInvoked when this handler is added to the pipeline.This is typically the first lifecycle method called for a handler.
- Specified by:
onHandlerAddedin interfaceHandler- Parameters:
ctx- theContextthis handler is bound to.
-
onHandlerRemoved
Description copied from interface:HandlerInvoked just before this handler is removed from the pipeline.This allows the handler to perform any necessary cleanup.
- Specified by:
onHandlerRemovedin interfaceHandler- Parameters:
ctx- theContextthis handler is bound to.
-
getLogger
protected abstract org.slf4j.Logger getLogger()Returns the logger of the subclass.- Returns:
- the logger
-