2. ABOUT RICK HIGHTOWER
ABOUT RICK
• Implemented Microservices, Vert.x/Netty at massive scale
• Author of QBit, microservices lib and Boon, Json parser and utility lib
• Founder of Mammatus Technology
• Rick’s Twitter, Rick’s LinkedIn, Rick’s Blog, Rick’s Slideshare
8. EVENTLOOP
INTERFACE EVENTLOOP
• Core abstraction for handling connection events
• EventLoopGroup contains one or more EventLoops
• EventLoop is bound to a single thread
• IO Events handles by single thread
• Channel is registered to a single EventLoop
• eliminates most needs for synchronization
• EventLoop can handle many channels
9. CHANNELFUTURE
CHANNEL FUTURE
• ChannelFuture to handle async operations
• Determine results at a later time
• addListener() to register callback for completion
• When it gets executed depends but they are executed in order of
receipt
10. CHANNEL HANDLER
CHANNEL HANDLER
• ChannelHandler used to implement application logic
• Handles inbound and outbound data
• methods are triggered by network events
• ChannelInboundHandler sub-interface handles incoming events
• gets implemented often for application logic
• allows you to flush data going to client
• your business logic will often rely here
11. CHANNELPIPELINE
CHANNEL PIPELINE
• ChannelPipeline
• forms chain of ChannelHandlers
• Channel is assigned a ChannelPipeline
• ChannelHandlers are registered with a ChannelIntializer
• ChannelHandlers operate on events by processing them and then
passing the event to the next handler in the chain
12. INBOUND MESSAGES GET DECODED
OUTBOUND MESSAGES GET ENCODED
ENCODERS AND DECODERS
• Inbound messages get DECODED
• Outbound messages get ENCODED
• Converting from bytes to Java objects or serializing Java objects to bytes
• Examples: ByteToMessageDecoder, MessageToByteEncoder,
ProtobufEncoder, ProtobufDecoder
• encode(), decode()
• Encoded messages get passed to next ChannelInboundHandler
• Decode messages get passed to next ChannelOutboundHandler
13. STARTING UP A CLIENT OR A SERVER
BOOTSTRAPPING
• Bootstrap - client bootstrap
• uses one thread
• ServerBootstrap - server bootstrap
• binds to a port
• uses two threads
• needs two channels one for listening and a second channel for handling
clients connections
• first channel creates Channels for incoming connections which get
assigned to an EventLoop
20. ABOUT RICK HIGHTOWER
ABOUT RICK
• Implemented Microservices, Vert.x/Netty at massive scale
• Author of QBit, microservices lib and Boon, Json parser and utility lib
• Founder of Mammatus Technology
• Rick’s Twitter, Rick’s LinkedIn, Rick’s Blog, Rick’s Slideshare