Class ResponseClient

java.lang.Object
io.aeron.response.ResponseClient
All Implemented Interfaces:
AutoCloseable, Agent

public class ResponseClient extends Object implements AutoCloseable, Agent
Sample client to be used with the response server.
  • Constructor Details

    • ResponseClient

      public ResponseClient(Aeron aeron, FragmentHandler handler, String requestEndpoint, int requestStreamId, String responseControl, int responseStreamId, String requestChannel, String responseChannel)
      Construct a response client with the associated request endpoint. The response endpoint is not required as the server will manage sending this to the client
      Parameters:
      aeron - client to use to connect to the server.
      handler - callback to handle response messages.
      requestEndpoint - request publication's endpoint.
      requestStreamId - request publication streamId
      responseControl - control address for the response subscription.
      responseStreamId - response response streamId
      requestChannel - channel fragment to allow for configuration of parameters on the request publication. May be null. The 'endpoint' parameter is not required and will be replaced by the requestEndpoint if specified.
      responseChannel - channel fragment to allow for configuration parameters on the response subscription. May be null. The 'control' parameter is not required and will be removed if specified.
    • ResponseClient

      public ResponseClient(Aeron aeron, FragmentHandler handler, String requestEndpoint, int requestStreamId, String responseControl, int responseStreamId)
      Overload for ResponseServer(Aeron, Function, String, int, String, int, String, String) that defaults the channels to null.
      Parameters:
      aeron - client to use to connect to the server.
      handler - callback to handle response messages.
      requestEndpoint - request publication's endpoint.
      requestStreamId - request publication streamId
      responseControl - control address for the response subscription.
      responseStreamId - response response streamId
  • Method Details

    • doWork

      public int doWork()
      Specified by:
      doWork in interface Agent
    • roleName

      public String roleName()
      Specified by:
      roleName in interface Agent
    • close

      public void close()
      Specified by:
      close in interface AutoCloseable
    • isConnected

      public boolean isConnected()
      Check that the client is connected.
      Returns:
      true if the client is connected.
    • offer

      public long offer(DirectBuffer message)
      Offer a message on the request channel.
      Parameters:
      message - to be sent
      Returns:
      result code from the publication.
    • responseControl

      public String responseControl()
      Get the response control for the server.
      Returns:
      response control for the server.
    • requestEndpoint

      public String requestEndpoint()
      Get the request endpoint for the server.
      Returns:
      request endpoint for the server.
    • subscription

      public Subscription subscription()
      Get the response subscription for the client.
      Returns:
      response subscription for the client.
    • publication

      public ExclusivePublication publication()
      Get the request publication for the client.
      Returns:
      request publication for the client.
    • toString

      public String toString()
      Overrides:
      toString in class Object