Class ClientChannelPendingMessagesQueue

    • Constructor Detail

      • ClientChannelPendingMessagesQueue

        public ClientChannelPendingMessagesQueue​(ClientChannel channel)
    • Method Detail

      • getCompletedFuture

        public OpenFuture getCompletedFuture()
        Returns:
        An internal OpenFuture that can be used to wait for all internal pending messages to be flushed before actually signaling that operation is complete
      • isOpen

        public boolean isOpen()
        Specified by:
        isOpen in interface Channel
      • markClosed

        protected boolean markClosed()
        Marks the queue as closed
        Returns:
        true if was open and now is closed
      • handleIncomingMessage

        public int handleIncomingMessage​(Buffer buffer,
                                         Consumer<? super Throwable> errHandler)
                                  throws IOException
        Checks if the future is already open and manages the message handling accordingly:

        • If channel is not open yet, it enqueues the request
        • If channel is open but there are still pending messages not yet written out, it will wait for them to be written (or exception signaled) before proceeding to write out the incoming message.
        • Otherwise (i.e., channel is open and no pending messages yet) it will write the message to the underlying channel immediately.
        Parameters:
        buffer - The message Buffer
        errHandler - The error handler to invoke it had to enqueue the message and was unsuccessful in writing it. Must be non-null if future not open yet. Otherwise, if null and exception occurs it will be simple re-thrown
        Returns:
        The total number of still pending messages - zero if none and message was written (either immediately or after waiting for the pending ones to be written).
        Throws:
        IOException - If wrote the message directly, encountered an error and no handler was provided.
      • flushPendingQueue

        protected void flushPendingQueue()
      • markCompletionSuccessful

        protected OpenFuture markCompletionSuccessful()
      • clearPendingQueue

        protected int clearPendingQueue()