Class OnapMrFetchResponse

java.lang.Object
io.continual.onap.services.mrCommon.OnapMrResponse
io.continual.onap.services.subscriber.OnapMrFetchResponse

public class OnapMrFetchResponse extends OnapMrResponse
  • Constructor Details

    • OnapMrFetchResponse

      public OnapMrFetchResponse(int statusCode, String statusMsg)
      Construct this response with an empty set of messages and no EOF.
      Parameters:
      statusCode - the HTTP status code
      statusMsg - the HTTP status text
    • OnapMrFetchResponse

      public OnapMrFetchResponse(int statusCode, String statusMsg, List<String> msgs)
      Construct this response with a finished set of messages.
      Parameters:
      statusCode - the HTTP status code
      statusMsg - the HTTP status text
      msgs - the set of messages in the response
  • Method Details

    • push

      public OnapMrFetchResponse push(String msg)
      Push a message into this response
      Parameters:
      msg - a message from the service
      Returns:
      this response
    • markEof

      public OnapMrFetchResponse markEof()
      Mark the response stream as being at its end
      Returns:
      this response
    • isEof

      public boolean isEof()
      Is this response at the end of its stream, with all pending messages consumed?
      Returns:
      true if there are no more messages
    • readyCount

      public int readyCount()
      Get the number of pending messages in the response. This count does not include messages that have not yet been delivered via the response stream.
      Returns:
      the count of pending messages
    • consumeNext

      public String consumeNext(long timeoutMs) throws InterruptedException
      Fetch the next message in this response.
      Parameters:
      timeoutMs - the length of time to wait for the next message (which could potentially be in-flight)
      Returns:
      a message, or null if all of the response has been consumed
      Throws:
      InterruptedException - if the wait is interrupted
    • getMessages

      @Deprecated public List<String> getMessages()
      Deprecated.
      Client code should call consumeNext() with a timeout value set
      Consume all messages in the response, blocking until the end of the stream.
      Returns:
      a list of messages