私はこのような非同期ハンドラメソッドを持っています
@RequestMapping("/custom-timeout-handling")
public @ResponseBody WebAsyncTask<String> callableWithCustomTimeoutHandling() {
Callable<String> callable = new Callable<String>() {
public String call() throws Exception {
while(i==0){
System.out.println("inside while loop->");
}
return "Callable result";
}
};
return new WebAsyncTask<String>(10000, callable);
}
指定されたタイムアウト (10 秒) まで while ループを実行します。
リクエストがタイムアウトすると、TimeoutCallableProcessingInterceptor から handleTimeout メソッドを実行する
public class TimeoutCallableProcessingInterceptor extends CallableProcessingInterceptorAdapter {
@Override
public <T> Object handleTimeout(NativeWebRequest request, Callable<T> task) throws Exception {
throw new IllegalStateException("[" + task.getClass().getName() + "] timed out");
}
}
引用元:交換しました
Thread.sleep(2000)
と
while(i==0){
System.out.println("inside while loop->");
}
私の問題は、タイムアウト(ハンドルタイムアウトメソッドの実行が終了した)応答がhandletimeoutメソッドから送信された後でも、iの値がゼロ以外の値に変更されるまで、whileループがまだ処理されていることです。
リクエストはまだサーバーによって保持されていますか?では、リクエストタイムアウトの使用は何ですか?
前もって感謝します...