An async scenario starts with request processing as usual in a thread (T1).
Concurrent request handling can be initiated by calling
startCallableProcessing or
startDeferredResultProcessing,
both of which produce a result in a separate thread (T2). The result is saved
and the request dispatched to the container, to resume processing with the saved
result in a third thread (T3). Within the dispatched thread (T3), the saved
result can be accessed via getConcurrentResult() or its presence
detected via hasConcurrentResult().
org.springframework.web.context.request.AsyncWebRequestInterceptor , org.springframework.web.servlet.AsyncHandlerInterceptor , org.springframework.web.filter.OncePerRequestFilter#shouldNotFilterAsyncDispatch , org.springframework.web.filter.OncePerRequestFilter#isAsyncDispatch
| Modifier and Type | Field and Description |
|---|---|
| private AsyncWebRequest | |
| private final Map | |
| private volatile Object | |
| private volatile Object[] | |
| private static final AsyncTaskExecutor | |
| private final Map | |
| private static final String | DISCONNECTED_CLIENT_LOG_CATEGORY
Log category to use for network failure after a client has gone away. |
| private static final DisconnectedClientHelper | |
| private volatile boolean | |
| private static final Log | |
| private static final Object | |
| private AsyncTaskExecutor | |
| private static final CallableProcessingInterceptor | |
| private static final DeferredResultProcessingInterceptor |
| Access | Constructor and Description |
|---|---|
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| public void | |
| private String | |
| public CallableProcessingInterceptor | Returns: the interceptor registered under that key, ornull if nonethe key key)Get the |
| public Object | Returns: an Object, possibly anException or Throwable if
concurrent handling raised one.Provides access to the result from concurrent handling. |
| public Object[] | getConcurrentResultContext()
Provides access to additional processing context saved at the start of concurrent handling. |
| public DeferredResultProcessingInterceptor | Returns: the interceptor registered under that key, ornull if nonethe key key)Get the |
| public boolean | |
| public boolean | isConcurrentHandlingStarted()
Whether the selected handler for the current request chose to handle the request asynchronously. |
| public void | registerCallableInterceptor(Object
the key key, CallableProcessingInterceptor the interceptor to register interceptor)Register a |
| public void | registerCallableInterceptors(CallableProcessingInterceptor...
one or more interceptors to register interceptors)Register a |
| public void | registerDeferredResultInterceptor(Object
the key key, DeferredResultProcessingInterceptor the interceptor to register interceptor)Register a |
| public void | registerDeferredResultInterceptors(DeferredResultProcessingInterceptor...
one or more interceptors to register interceptors)Register one or more |
| public void | setAsyncWebRequest(AsyncWebRequest
the web request to use asyncWebRequest)Configure the |
| private void | |
| public void | setTaskExecutor(AsyncTaskExecutor taskExecutor)
Configure an AsyncTaskExecutor for use with concurrent processing via
|
| private void | |
| public void | startCallableProcessing(Callable<?>
a unit of work to be executed asynchronously callable, Object... additional context to save that can be accessed
via processingContext)getConcurrentResultContext()Start concurrent request processing and execute the given task with an
|
| public void | startCallableProcessing(final WebAsyncTask<?>
a WebAsyncTask containing the target webAsyncTask, Object... Callableadditional context to save that can be accessed
via processingContext)getConcurrentResultContext()Use the given |
| public void | startDeferredResultProcessing(final DeferredResult<?>
the DeferredResult instance to initialize deferredResult, Object... additional context to save that can be accessed
via processingContext)getConcurrentResultContext()Start concurrent request processing and initialize the given
|
| asyncWebRequest | back to summary |
|---|---|
| private AsyncWebRequest asyncWebRequest
| |
| callableInterceptors | back to summary |
|---|---|
| private final Map<Object, CallableProcessingInterceptor> callableInterceptors | |
| concurrentResult | back to summary |
|---|---|
| private volatile Object concurrentResult
| |
| concurrentResultContext | back to summary |
|---|---|
| private volatile Object[] concurrentResultContext
| |
| DEFAULT_TASK_EXECUTOR | back to summary |
|---|---|
| private static final AsyncTaskExecutor DEFAULT_TASK_EXECUTOR | |
| deferredResultInterceptors | back to summary |
|---|---|
| private final Map<Object, DeferredResultProcessingInterceptor> deferredResultInterceptors | |
| DISCONNECTED_CLIENT_LOG_CATEGORY | back to summary |
|---|---|
| private static final String DISCONNECTED_CLIENT_LOG_CATEGORY Log category to use for network failure after a client has gone away.
| |
| disconnectedClientHelper | back to summary |
|---|---|
| private static final DisconnectedClientHelper disconnectedClientHelper | |
| errorHandlingInProgress | back to summary |
|---|---|
| private volatile boolean errorHandlingInProgress | |
| logger | back to summary |
|---|---|
| private static final Log logger | |
| RESULT_NONE | back to summary |
|---|---|
| private static final Object RESULT_NONE | |
| taskExecutor | back to summary |
|---|---|
| private AsyncTaskExecutor taskExecutor | |
| timeoutCallableInterceptor | back to summary |
|---|---|
| private static final CallableProcessingInterceptor timeoutCallableInterceptor | |
| timeoutDeferredResultInterceptor | back to summary |
|---|---|
| private static final DeferredResultProcessingInterceptor timeoutDeferredResultInterceptor | |
| WebAsyncManager | back to summary |
|---|---|
| pack-priv WebAsyncManager() Package-private constructor. | |
| clearConcurrentResult | back to summary |
|---|---|
| public void clearConcurrentResult() Clear concurrentResult and concurrentResultContext. | |
| formatRequestUri | back to summary |
|---|---|
| private String formatRequestUri() | |
| getCallableInterceptor | back to summary |
|---|---|
| public CallableProcessingInterceptor getCallableInterceptor(Object key) Get the
| |
| getConcurrentResult | back to summary |
|---|---|
| public Object getConcurrentResult() Provides access to the result from concurrent handling.
| |
| getConcurrentResultContext | back to summary |
|---|---|
| public Object[] getConcurrentResultContext() Provides access to additional processing context saved at the start of concurrent handling.
| |
| getDeferredResultInterceptor | back to summary |
|---|---|
| public DeferredResultProcessingInterceptor getDeferredResultInterceptor(Object key) Get the
| |
| hasConcurrentResult | back to summary |
|---|---|
| public boolean hasConcurrentResult() Whether a result value exists as a result of concurrent handling. | |
| isConcurrentHandlingStarted | back to summary |
|---|---|
| public boolean isConcurrentHandlingStarted() Whether the selected handler for the current request chose to handle the request asynchronously. A return value of "true" indicates concurrent handling is under way and the response will remain open. A return value of "false" means concurrent handling was either not started or possibly that it has completed and the request was dispatched for further processing of the concurrent result. | |
| registerCallableInterceptor | back to summary |
|---|---|
| public void registerCallableInterceptor(Object key, CallableProcessingInterceptor interceptor) Register a
| |
| registerCallableInterceptors | back to summary |
|---|---|
| public void registerCallableInterceptors(CallableProcessingInterceptor... interceptors) Register a
| |
| registerDeferredResultInterceptor | back to summary |
|---|---|
| public void registerDeferredResultInterceptor(Object key, DeferredResultProcessingInterceptor interceptor) Register a
| |
| registerDeferredResultInterceptors | back to summary |
|---|---|
| public void registerDeferredResultInterceptors(DeferredResultProcessingInterceptor... interceptors) Register one or more
| |
| setAsyncWebRequest | back to summary |
|---|---|
| public void setAsyncWebRequest(AsyncWebRequest asyncWebRequest) Configure the
| |
| setConcurrentResultAndDispatch | back to summary |
|---|---|
| private void setConcurrentResultAndDispatch(Object result) | |
| setTaskExecutor | back to summary |
|---|---|
| public void setTaskExecutor(AsyncTaskExecutor taskExecutor) Configure an AsyncTaskExecutor for use with concurrent processing via
By default a | |
| startAsyncProcessing | back to summary |
|---|---|
| private void startAsyncProcessing(Object[] processingContext) | |
| startCallableProcessing | back to summary |
|---|---|
| public void startCallableProcessing(Callable<?> callable, Object... processingContext) throws Exception Start concurrent request processing and execute the given task with an
| |
| startCallableProcessing | back to summary |
|---|---|
| public void startCallableProcessing(final WebAsyncTask<?> webAsyncTask, Object... processingContext) throws Exception Use the given
| |
| startDeferredResultProcessing | back to summary |
|---|---|
| public void startDeferredResultProcessing(final DeferredResult<?> deferredResult, Object... processingContext) throws Exception Start concurrent request processing and initialize the given
| |