Package io.micronaut.http.netty.reactive
Class HandlerSubscriber<T>
java.lang.Object
io.netty.channel.ChannelHandlerAdapter
io.netty.channel.ChannelInboundHandlerAdapter
io.netty.channel.ChannelDuplexHandler
io.micronaut.http.netty.reactive.HandlerSubscriber<T>
- Type Parameters:
T
- The subscriber type
- All Implemented Interfaces:
io.netty.channel.ChannelHandler
,io.netty.channel.ChannelInboundHandler
,io.netty.channel.ChannelOutboundHandler
,Subscriber<T>
@Internal
public class HandlerSubscriber<T>
extends io.netty.channel.ChannelDuplexHandler
implements Subscriber<T>
Subscriber that publishes received messages to the handler pipeline.
- Since:
- 1.0
- Author:
- Graeme Rocher
-
Nested Class Summary
Nested classes/interfaces inherited from interface io.netty.channel.ChannelHandler
io.netty.channel.ChannelHandler.Sharable
-
Field Summary
-
Constructor Summary
ConstructorDescriptionHandlerSubscriber
(io.netty.util.concurrent.EventExecutor executor) Create a new handler subscriber with the default low and high watermarks. -
Method Summary
Modifier and TypeMethodDescriptionvoid
channelActive
(io.netty.channel.ChannelHandlerContext ctx) void
channelInactive
(io.netty.channel.ChannelHandlerContext ctx) void
channelRegistered
(io.netty.channel.ChannelHandlerContext ctx) void
channelWritabilityChanged
(io.netty.channel.ChannelHandlerContext ctx) protected void
complete()
Override for custom completion handling.protected void
Override for custom error handling.void
exceptionCaught
(io.netty.channel.ChannelHandlerContext ctx, Throwable cause) void
handlerAdded
(io.netty.channel.ChannelHandlerContext ctx) void
handlerRemoved
(io.netty.channel.ChannelHandlerContext ctx) void
void
void
protected void
Write the message with the supplied promise.void
onSubscribe
(Subscription subscription) Methods inherited from class io.netty.channel.ChannelDuplexHandler
bind, close, connect, deregister, disconnect, flush, read, write
Methods inherited from class io.netty.channel.ChannelInboundHandlerAdapter
channelRead, channelReadComplete, channelUnregistered, userEventTriggered
Methods inherited from class io.netty.channel.ChannelHandlerAdapter
ensureNotSharable, isSharable
-
Field Details
-
lastWriteFuture
protected io.netty.channel.ChannelFuture lastWriteFuture
-
-
Constructor Details
-
HandlerSubscriber
public HandlerSubscriber(io.netty.util.concurrent.EventExecutor executor) Create a new handler subscriber with the default low and high watermarks.The supplied executor must be the same event loop as the event loop that this handler is eventually registered with, if not, an exception will be thrown when the handler is registered.
- Parameters:
executor
- The executor to execute asynchronous events from the publisher on.
-
-
Method Details
-
error
Override for custom error handling. By default, it closes the channel.- Parameters:
error
- The error to handle.
-
complete
protected void complete()Override for custom completion handling. By default, it closes the channel. -
handlerAdded
public void handlerAdded(io.netty.channel.ChannelHandlerContext ctx) - Specified by:
handlerAdded
in interfaceio.netty.channel.ChannelHandler
- Overrides:
handlerAdded
in classio.netty.channel.ChannelHandlerAdapter
-
channelRegistered
public void channelRegistered(io.netty.channel.ChannelHandlerContext ctx) - Specified by:
channelRegistered
in interfaceio.netty.channel.ChannelInboundHandler
- Overrides:
channelRegistered
in classio.netty.channel.ChannelInboundHandlerAdapter
-
channelWritabilityChanged
public void channelWritabilityChanged(io.netty.channel.ChannelHandlerContext ctx) - Specified by:
channelWritabilityChanged
in interfaceio.netty.channel.ChannelInboundHandler
- Overrides:
channelWritabilityChanged
in classio.netty.channel.ChannelInboundHandlerAdapter
-
channelActive
public void channelActive(io.netty.channel.ChannelHandlerContext ctx) - Specified by:
channelActive
in interfaceio.netty.channel.ChannelInboundHandler
- Overrides:
channelActive
in classio.netty.channel.ChannelInboundHandlerAdapter
-
channelInactive
public void channelInactive(io.netty.channel.ChannelHandlerContext ctx) - Specified by:
channelInactive
in interfaceio.netty.channel.ChannelInboundHandler
- Overrides:
channelInactive
in classio.netty.channel.ChannelInboundHandlerAdapter
-
handlerRemoved
public void handlerRemoved(io.netty.channel.ChannelHandlerContext ctx) - Specified by:
handlerRemoved
in interfaceio.netty.channel.ChannelHandler
- Overrides:
handlerRemoved
in classio.netty.channel.ChannelHandlerAdapter
-
exceptionCaught
- Specified by:
exceptionCaught
in interfaceio.netty.channel.ChannelHandler
- Specified by:
exceptionCaught
in interfaceio.netty.channel.ChannelInboundHandler
- Overrides:
exceptionCaught
in classio.netty.channel.ChannelInboundHandlerAdapter
-
onSubscribe
- Specified by:
onSubscribe
in interfaceSubscriber<T>
-
onNext
- Specified by:
onNext
in interfaceSubscriber<T>
-
onNext
Write the message with the supplied promise.- Parameters:
t
- The messagepromise
- The promise
-
onError
- Specified by:
onError
in interfaceSubscriber<T>
-
onComplete
public void onComplete()- Specified by:
onComplete
in interfaceSubscriber<T>
-