Package io.aeron.response
Class ResponseServer
java.lang.Object
io.aeron.response.ResponseServer
- All Implemented Interfaces:
AutoCloseable,Agent
A basic sample response server that allows the users to specify a simple function to represent the handling of a
request and then return a response. This approach will be effective when request processing is very short. For
certain types of response servers, e.g. returning a large volume of data from a database, this pattern will be
ineffective. For those types of use cases, something more complex, likely involving thread pooling would be required.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceInterface to manage callback from the response server onto a session. -
Constructor Summary
ConstructorsConstructorDescriptionResponseServer(Aeron aeron, Function<Image, ResponseServer.ResponseHandler> handlerFactory, String requestEndpoint, int requestStreamId, String responseControl, int responseStreamId, String requestChannel, String responseChannel) Constructs the server. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()intdoWork()Poll the server process messages and state.roleName()intThe number of connected clients.voidusePrototype(boolean usePrototype) Indicate whether or not to create a prototype response publication.
-
Constructor Details
-
ResponseServer
public ResponseServer(Aeron aeron, Function<Image, ResponseServer.ResponseHandler> handlerFactory, String requestEndpoint, int requestStreamId, String responseControl, int responseStreamId, String requestChannel, String responseChannel) Constructs the server.- Parameters:
aeron- connected Aeron client.handlerFactory- factor to produce handler instances for each incoming session.requestEndpoint- channel to listen for requests and new connections.requestStreamId- streamId to listen for requests and new connections.responseControl- channel to send responses back on.responseStreamId- streamId to send responses back on.requestChannel- fragment to aid in configuration of the subscription (can be null)responseChannel- fragment to aid in configuration of the response publication (can be null)
-
-
Method Details
-
usePrototype
public void usePrototype(boolean usePrototype) Indicate whether or not to create a prototype response publication.- Parameters:
usePrototype- true or false.
-
doWork
public int doWork()Poll the server process messages and state. -
sessionCount
public int sessionCount()The number of connected clients.- Returns:
- the number of connected clients.
-
close
public void close()- Specified by:
closein interfaceAutoCloseable
-
roleName
-