At the moment I'm using multiple REST services to process my data. A workflow would be like this:
User requests the speed of a car: Ask the SpeedService the most recent speed => SpeedService requests the latests positions of the car from the PositionService and the PositionService achieves this by calling the DatabaseService in order to get the raw unprocessed data from the car. However the part where I'm having issues is calling a service withing another service. I've achieved this for now by making uses of the invocation api.
Example:
Client client = ClientBuilder.newClient();
WebTarget target = client.target("http://mylocalRestserver.example/webresources/").path("speed");
target = target.queryParam("carId", carId);
Invocation invocation = target.request(MediaType.APPLICATION_JSON).buildGet();
Speed speed = new Genson().deserialize(invocation.invoke(String.class), Speed.class);
return speed;
However whenever I try to simulate concurrent users - running multiple curl queries - the REST service breaks due to SocketTimeouts, I assume because multiple requests are sent on the same serversocket? Is there any way to achieve this "chaining of services"?