Package io.aeron.response
Class ResponseClient
java.lang.Object
io.aeron.response.ResponseClient
- All Implemented Interfaces:
AutoCloseable,Agent
Sample client to be used with the response server.
-
Constructor Summary
ConstructorsConstructorDescriptionResponseClient(Aeron aeron, FragmentHandler handler, String requestEndpoint, int requestStreamId, String responseControl, int responseStreamId) Overload forResponseServer(Aeron, Function, String, int, String, int, String, String)that defaults the channels to null.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. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()intdoWork()booleanCheck that the client is connected.longoffer(DirectBuffer message) Offer a message on the request channel.Get the request publication for the client.Get the request endpoint for the server.Get the response control for the server.roleName()Get the response subscription for the client.toString()
-
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 streamIdresponseControl- control address for the response subscription.responseStreamId- response response streamIdrequestChannel- 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 therequestEndpointif 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 forResponseServer(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 streamIdresponseControl- control address for the response subscription.responseStreamId- response response streamId
-
-
Method Details
-
doWork
public int doWork() -
roleName
-
close
public void close()- Specified by:
closein interfaceAutoCloseable
-
isConnected
public boolean isConnected()Check that the client is connected.- Returns:
- true if the client is connected.
-
offer
Offer a message on the request channel.- Parameters:
message- to be sent- Returns:
- result code from the publication.
-
responseControl
Get the response control for the server.- Returns:
- response control for the server.
-
requestEndpoint
Get the request endpoint for the server.- Returns:
- request endpoint for the server.
-
subscription
Get the response subscription for the client.- Returns:
- response subscription for the client.
-
publication
Get the request publication for the client.- Returns:
- request publication for the client.
-
toString
-