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.Logger
Returns the logger of the subclass.void
handleInboundFailure
(Context ctx, Throwable cause) Invoked when an error occurs during the processing of an inbound message.void
handleInboundMessage
(Context ctx, InboundMessage msg) Invoked when an inbound message is received and propagated through the pipeline.void
handleOutboundMessage
(Context ctx, OutboundMessage msg, CompletableFuture<Void> future) Invoked when an outbound message is propagated through the pipeline.void
handleUserEvent
(Context ctx, Object evt) Invoked when a user-defined event is propagated through the pipeline.void
Invoked when the connection associated with this context becomes active.void
Invoked when the connection associated with this context becomes inactive.void
onHandlerAdded
(Context ctx) Invoked when this handler is added to the pipeline.void
onHandlerRemoved
(Context ctx) Invoked just before this handler is removed from the pipeline.
-
Constructor Details
-
AbstractDuplexHandler
public AbstractDuplexHandler()
-
-
Method Details
-
handleInboundFailure
Description copied from interface:InboundHandler
Invoked 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:
handleInboundFailure
in interfaceInboundHandler
- Parameters:
ctx
- theContext
this handler is bound to.cause
- theThrowable
describing the failure.
-
handleInboundMessage
Description copied from interface:InboundHandler
Invoked 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:
handleInboundMessage
in interfaceInboundHandler
- Parameters:
ctx
- theContext
this handler is bound to.msg
- theInboundMessage
being processed.
-
handleOutboundMessage
Description copied from interface:OutboundHandler
Invoked when an outbound message is propagated through the pipeline.This method is responsible for handling or forwarding the outbound
OutboundMessage
. Completion of the providedCompletableFuture
signals the success or failure of the operation.- Specified by:
handleOutboundMessage
in interfaceOutboundHandler
- Parameters:
ctx
- theContext
this 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:Handler
Invoked 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:
handleUserEvent
in interfaceHandler
- Parameters:
ctx
- theContext
this handler is bound to.evt
- the user-defined event to handle.
-
onConnectionActive
Description copied from interface:Handler
Invoked when the connection associated with this context becomes active.- Specified by:
onConnectionActive
in interfaceHandler
- Parameters:
ctx
- theContext
this handler is bound to.
-
onConnectionInactive
Description copied from interface:Handler
Invoked when the connection associated with this context becomes inactive.- Specified by:
onConnectionInactive
in interfaceHandler
- Parameters:
ctx
- theContext
this handler is bound to.
-
onHandlerAdded
Description copied from interface:Handler
Invoked when this handler is added to the pipeline.This is typically the first lifecycle method called for a handler.
- Specified by:
onHandlerAdded
in interfaceHandler
- Parameters:
ctx
- theContext
this handler is bound to.
-
onHandlerRemoved
Description copied from interface:Handler
Invoked just before this handler is removed from the pipeline.This allows the handler to perform any necessary cleanup.
- Specified by:
onHandlerRemoved
in interfaceHandler
- Parameters:
ctx
- theContext
this handler is bound to.
-
getLogger
protected abstract org.slf4j.Logger getLogger()Returns the logger of the subclass.- Returns:
- the logger
-