类 TimeoutAsyncProcessingInterceptor
java.lang.Object
cn.taketoday.web.context.async.TimeoutAsyncProcessingInterceptor
public class TimeoutAsyncProcessingInterceptor
extends Object
implements CallableProcessingInterceptor, DeferredResultProcessingInterceptor
Sends a 503 (SERVICE_UNAVAILABLE) in case of a timeout if the response is not
already committed. this is done indirectly by setting the result
to an
AsyncRequestTimeoutException which is then handled by
MVC's default exception handling as a 503 error.
Registered at the end, after all other interceptors and therefore invoked only if no other interceptor handles the timeout.
Note that according to RFC 7231, a 503 without a 'Retry-After' header is interpreted as a 500 error and the client should not retry. Applications can install their own interceptor to handle a timeout and add a 'Retry-After' header if necessary.
- 从以下版本开始:
- 4.0
- 作者:
- Rossen Stoyanchev, Harry Yang
-
字段概要
从接口继承的字段 cn.taketoday.web.context.async.CallableProcessingInterceptor
RESPONSE_HANDLED, RESULT_NONE -
构造器概要
构造器 -
方法概要
修饰符和类型方法说明<T> booleanhandleTimeout(RequestContext request, DeferredResult<T> result) Invoked from a container thread when an async request times out before theDeferredResulthas been set.<T> ObjecthandleTimeout(RequestContext request, Callable<T> task) Invoked from a container thread when the async request times out before theCallabletask completes.从类继承的方法 java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait从接口继承的方法 cn.taketoday.web.context.async.CallableProcessingInterceptor
afterCompletion, beforeConcurrentHandling, handleError, postProcess, preProcess从接口继承的方法 cn.taketoday.web.context.async.DeferredResultProcessingInterceptor
afterCompletion, beforeConcurrentHandling, handleError, postProcess, preProcess
-
构造器详细资料
-
TimeoutAsyncProcessingInterceptor
public TimeoutAsyncProcessingInterceptor()
-
-
方法详细资料
-
handleTimeout
从接口复制的说明:CallableProcessingInterceptorInvoked from a container thread when the async request times out before theCallabletask completes. Implementations may return a value, including anException, to use instead of the value theCallabledid not return in time.The default implementation always returns
CallableProcessingInterceptor.RESULT_NONE.- 指定者:
handleTimeout在接口中CallableProcessingInterceptor- 参数:
request- the current requesttask- the task for the current async request- 返回:
- a concurrent result value; if the value is anything other than
CallableProcessingInterceptor.RESULT_NONEorCallableProcessingInterceptor.RESPONSE_HANDLED, concurrent processing is resumed and subsequent interceptors are not invoked
-
handleTimeout
从接口复制的说明:DeferredResultProcessingInterceptorInvoked from a container thread when an async request times out before theDeferredResulthas been set. Implementations may invokesetResultorsetErrorResultto resume processing.- 指定者:
handleTimeout在接口中DeferredResultProcessingInterceptor- 参数:
request- the current requestresult- the DeferredResult for the current request; if theDeferredResultis set, then concurrent processing is resumed and subsequent interceptors are not invoked- 返回:
trueif processing should continue, orfalseif other interceptors should not be invoked
-