Class StreamMessageProducer

  • All Implemented Interfaces:
    java.io.Closeable, java.lang.AutoCloseable, MessageConstants, MessageProducer

    public class StreamMessageProducer
    extends java.lang.Object
    implements MessageProducer, java.io.Closeable, MessageConstants
    A message producer that reads from an input stream and parses messages from JSON.
    • Method Detail

      • getInput

        public java.io.InputStream getInput()
      • setInput

        public void setInput​(java.io.InputStream input)
      • listen

        public void listen​(MessageConsumer callback)
        Description copied from interface: MessageProducer
        Listen to a message source and forward all messages to the given consumer. Typically this method blocks until the message source is unable to deliver more messages.
        Specified by:
        listen in interface MessageProducer
      • fireError

        protected void fireError​(java.lang.Throwable error)
        Log an error.
      • fireStreamClosed

        protected void fireStreamClosed​(java.lang.Exception cause)
        Report that the stream was closed through an exception.
      • handleMessage

        protected boolean handleMessage​(java.io.InputStream input,
                                        StreamMessageProducer.Headers headers)
                                 throws java.io.IOException
        Read the JSON content part of a message, parse it, and notify the callback.
        Returns:
        true if we should continue reading from the input stream, false if we should stop
        Throws:
        java.io.IOException
      • close

        public void close()
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.io.Closeable