Class AsyncMessageOutputPlus

  • All Implemented Interfaces:
    java.io.Closeable, java.io.DataOutput, java.io.Flushable, java.lang.AutoCloseable, DataOutputPlus

    public class AsyncMessageOutputPlus
    extends AsyncChannelOutputPlus
    A DataOutputStreamPlus that writes ASYNCHRONOUSLY to a Netty Channel. Intended as single use, to write one (large) message. The close() and flush() methods synchronously wait for pending writes, and will propagate any exceptions encountered in writing them to the wire. The correctness of this class depends on the ChannelPromise we create against a Channel always being completed, which appears to be a guarantee provided by Netty so long as the event loop is running.
    • Method Detail

      • doFlush

        protected void doFlush​(int count)
                        throws java.io.IOException
        Specified by:
        doFlush in class AsyncChannelOutputPlus
        Throws:
        java.io.IOException
      • close

        public void close()
                   throws java.io.IOException
        Description copied from class: AsyncChannelOutputPlus
        Flush any remaining writes, and release any buffers. The channel is not closed, as it is assumed to be managed externally. WARNING: This method requires mutual exclusivity with all other producer methods to run safely. It should only be invoked by the owning thread, never the eventLoop; the eventLoop should propagate errors to AsyncChannelOutputPlus.flushFailed, which will propagate them to the producer thread no later than its final invocation to AsyncChannelOutputPlus.close() or AsyncChannelOutputPlus.flush() (that must not be followed by any further writes).
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.io.Closeable
        Overrides:
        close in class AsyncChannelOutputPlus
        Throws:
        java.io.IOException
      • discard

        public void discard()
        Discard any buffered data, and the buffers that contain it. May be invoked instead of close() if we terminate exceptionally.
        Specified by:
        discard in class AsyncChannelOutputPlus