Interface ProtocolMessageHandler<MessageType>
- All Superinterfaces:
ProtocolHandler
- All Known Implementing Classes:
ProtocolMessageHandler.Null
User: dsmith Date: Oct 7, 2010
This interface serves the same role as ProtocolHandler, but breaks processing up into two stages - message decoding,
and application-level processing. This is to enable implementations that must do long-running or (gasp) synchronous
NIO calls (e.g. CommClient.sendCommand) while handling a message.
Message decoding happens while synchronized on the associated IOJob, and hence must be fast operation in order to
avoid stalling delivery of data for this and other IOJobs with the current Scheduler/Job implementations. Message
handling has no such limitation - the only shared resource it consumes is a single NIODriver thread for its duration.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfaceFactory for creating message handlersstatic interfaceFactory for creating message handlers with an IOJobstatic classNull implementation -
Method Summary
Modifier and TypeMethodDescriptiondecodeSingleMessage(ByteBuffer buffer) Converts data from a ByteBuffer into a message for processing by handleMessage.voidhandleMessage(MessageType message) Does application-level processing of a message.Methods inherited from interface io.deephaven.enterprise.comm.protocol.ProtocolHandler
handleBuffer
-
Method Details
-
decodeSingleMessage
Converts data from a ByteBuffer into a message for processing by handleMessage. Implementations *must* ensure that buffer.position() reflects the data consumed before returning. Do *not* make synchronous NIO calls from this method (or do anything else long-running).- Parameters:
buffer- The buffer- Returns:
- A message for handleMessage to process, or null if the buffer does not contain a complete message
-
handleMessage
Does application-level processing of a message.- Parameters:
message- The message, previously returned by a call to decodeSingleMessage
-