Class DispatchedMessageSink
- All Implemented Interfaces:
MessageSink
- Direct Known Subclasses:
InputStreamMessageSink
,ReaderMessageSink
A Dispatched MessageSink can consist of 1 or more accept(Frame, Callback)
calls.
The first accept(Frame, Callback)
in a message will trigger a dispatch to the
function specified in the constructor.
The completion of the dispatched function call is the sign that the next message is suitable for processing from the network. (The connection fillAndParse should remain idle for the NEXT message until such time as the dispatched function call has completed)
There are a few use cases we need to handle.
1. Normal Processing
Connection Thread | DispatchedMessageSink | Thread 2 TEXT accept() - dispatch - function.read(stream) CONT accept() stream.read() CONT accept() stream.read() CONT=fin accept() stream.read() EOF stream.read EOF IDLE exit method RESUME(NEXT MSG)
2. Early Exit (with no activity)
Connection Thread | DispatchedMessageSink | Thread 2 TEXT accept() - dispatch - function.read(stream) CONT accept() exit method (normal return) IDLE TIMEOUT
3. Early Exit (due to exception)
Connection Thread | DispatchedMessageSink | Thread 2 TEXT accept() - dispatch - function.read(stream) CONT accept() exit method (throwable) callback.fail() endpoint.onError() close(error)
4. Early Exit (with Custom Threading)
Connection Thread | DispatchedMessageSink | Thread 2 | Thread 3 TEXT accept() - dispatch - function.read(stream) thread.new(stream) stream.read() exit method CONT accept() stream.read() CONT accept() stream.read() CONT=fin accept() stream.read() EOF stream.read EOF RESUME(NEXT MSG)
-
Field Summary
Fields inherited from class org.eclipse.jetty.websocket.core.internal.messages.AbstractMessageSink
methodHandle, session
-
Constructor Summary
-
Method Summary
-
Constructor Details
-
DispatchedMessageSink
-
-
Method Details
-
newSink
-
accept
Description copied from interface:MessageSink
Consume the frame payload to the message.- Parameters:
frame
- the frame, its payload (and fin state) to appendcallback
- the callback for how the frame was consumed
-
fail
Description copied from interface:MessageSink
Fail the message sink.
Release any resources and fail all stored callbacks as
MessageSink.accept(Frame, Callback)
will never be called again.- Specified by:
fail
in interfaceMessageSink
- Overrides:
fail
in classAbstractMessageSink
- Parameters:
failure
- the failure that occurred.
-