目前我正在使用多個REST服務來處理我的數據。 工作流程是這樣的:鏈接服務 - Java
用戶請求車的速度: 問SpeedService最近期速度=> SpeedService從PositionService要求汽車的latests位置和PositionService通過調用DatabaseService實現這一以便從汽車中獲取原始未處理的數據。然而,我遇到問題的部分是使用其他服務調用服務。現在我已經通過使用調用api來實現這一點。
例子:
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;
但是每當我試圖併發用戶模擬 - 運行多個捲曲查詢 - REST服務中斷是由於SocketTimeouts,我想是因爲多個請求在相同的ServerSocket發送?有沒有辦法實現這種「服務鏈」?