Вы можете использовать аннотацию Suspended
и создать TimeoutHandler
.
Не уверен, что вам нужно увеличить время ожидания в tomcat, используя этот пример.
public class Resource {
private Executor executor = Executors.newSingleThreadExecutor();
@GET
public void asyncGet(@Suspended final AsyncResponse asyncResponse) {
asyncResponse.setTimeoutHandler(new TimeoutHandler() {
@Override
public void handleTimeout(AsyncResponse asyncResponse) {
asyncResponse.resume("Processing timeout.");
executor.shutdown();
}
});
asyncResponse.setTimeout(60, TimeUnit.SECONDS);
executor.submit(() -> {
String result = someService.expensiveOperation();
asyncResponse.resume(result);
executor.shutdown();
});
}
}
Документация по Джерси здесь