Interface RequestContext

All Known Implementing Classes:
RequestHandler

public interface RequestContext
A request context is the asynchronous interface for working with a pending request. The context must be provided when sending a signal, and the RequestSink is obligated to send all replies to this context. The context will also be notified if the RequestSink closes the request, or notifies about an error.
  • Method Details

    • isClosed

      boolean isClosed()
      Returns:
      true if this request is closed down (will not accept any more responses)
    • keepAlive

      boolean keepAlive(long until)
      Request that this request should be kept alive a bit longer
      Parameters:
      until - Ask this request to keep open at least until this timestamp
      Returns:
      true if the request is granted (will not guarantee that endpoint clients keep this up)
    • notifyError

      void notifyError(Throwable e)
      Notify signal context that an error has occurred while waiting for data
      Parameters:
      e - exception that was caught
    • notifyClose

      void notifyClose()
      Notify signal context that server has closed this request. The request may already be closed on the client side.
    • addListener

      void addListener(RequestListener listener)
      Add a RequestListener to context. A context implementation should notify any registered listeners about relevant events.
      Parameters:
      listener - listener to add
    • removeListener

      void removeListener(RequestListener listener)
      Remove a RequestListener from context
      Parameters:
      listener - listener to remove
    • addResponse

      @Deprecated boolean addResponse(Message msg)
      Add a signal response to give back to requesting client
      Parameters:
      msg - the response message to add
      Returns:
      true if the response message was accepted, false if it was discarded
    • addResponse

      boolean addResponse(Message msg, ResponseListener responseListener)
      Add a signal response to give back to requesting client, with a acknoeldgement listener to notify when the response has been accepted. When using this method, clients MUST invoke ResponseListener.responseAccepted() when the response has been handled, else the sender may starve the client once the sender has sent responses enough to fill the agreed client buffer.
      Parameters:
      msg - the response message to add
      responseListener - listener to acknowledge to when the response has been accepted.
      Returns:
      true if the response message was accepted, false if it was discarded
    • endOfStream

      void endOfStream()
      Signal end of stream (the current context holder will not provide any more data).