使用 Awaitility 4.0.1,我整理了以下轮询,该轮询会以 10 秒的间隔轮询我的服务器 5 分钟的数据,并且运行得非常好:
AtomicReference<Response> response = null;
with().pollInterval(10, TimeUnit.SECONDS)
.and().timeout(5, TimeUnit.MINUTES)
.await("Retrieving data from server")
.until(() -> {
response = restClient.performGetRequest();
boolean isFilled = !response.readEntity(String.class).isEmpty();
return isFilled;
});
return response;
有没有办法从 Awaitility 中获取 - 在 until
lambda 中 - 重试尝试以及在失败之前它将执行的剩余重试次数?