Class ServerChannel<REQ,RESP>

java.lang.Object
io.bytestreams.exchange.core.AbstractChannel<RESP,REQ>
io.bytestreams.exchange.core.ServerChannel<REQ,RESP>
Type Parameters:
REQ - the request message type
RESP - the response message type
All Implemented Interfaces:
Channel

public class ServerChannel<REQ,RESP> extends AbstractChannel<RESP,REQ>
A Channel backed by a Transport that receives requests and dispatches them to a registered handler.

Two virtual threads drive the channel: a reader that decodes requests from the transport input stream and dispatches them to the registered handler, and a writer that drains the response queue and encodes responses to the transport output stream. When the handler completes the future provided by the reader, the response is enqueued for writing.

I/O and unexpected errors are routed to the ErrorHandler. If the handler returns true (the default), the channel closes the transport and completes its close future exceptionally. Return false to tolerate the error and continue processing. Unrecoverable errors that bypass the inner I/O catch (e.g. RuntimeException) are caught by an outer safety net that guarantees the close future always resolves.