Package org.springframework.web.context.request.async

# Interface AsyncWebRequest

All Superinterfaces:
  `NativeWebRequest`, `RequestAttributes`, `WebRequest`

All Known Implementing Classes:
  `StandardServletAsyncWebRequest`

public interface AsyncWebRequest extends NativeWebRequest
Extends `NativeWebRequest` with methods for asynchronous request processing.

Since:
  3.2
Author:
  Rossen Stoyanchev

## Field Summary

### Fields inherited from interface org.springframework.web.context.request.RequestAttributes

`REFERENCE_REQUEST, REFERENCE_SESSION, SCOPE_REQUEST, SCOPE_SESSION`

## Method Summary

Modifier and Type
Method
Description
`void`
`addCompletionHandler(Runnable runnable)`
Add a handler to invoke when request processing completes.
`void`
`addErrorHandler(Consumer<Throwable> exceptionHandler)`
Add a handler to invoke when an error occurred while concurrent handling of a request.
`void`
`addTimeoutHandler(Runnable runnable)`
Add a handler to invoke when concurrent handling has timed out.
`void`
`dispatch()`
Dispatch the request to the container in order to resume processing after concurrent execution in an application thread.
`boolean`
`isAsyncComplete()`
Whether asynchronous processing has completed.
`boolean`
`isAsyncStarted()`
Whether the request is in async mode following a call to `startAsync()`.
`void`
`setTimeout(Long timeout)`
Set the time required for concurrent handling to complete.
`void`
`startAsync()`
Mark the start of asynchronous request processing so that when the main processing thread exits, the response remains open for further processing in another thread.

### Methods inherited from interface org.springframework.web.context.request.NativeWebRequest

`getNativeRequest, getNativeRequest, getNativeResponse, getNativeResponse`

### Methods inherited from interface org.springframework.web.context.request.RequestAttributes

`getAttribute, getAttributeNames, getSessionId, getSessionMutex, registerDestructionCallback, removeAttribute, resolveReference, setAttribute`

### Methods inherited from interface org.springframework.web.context.request.WebRequest

`checkNotModified, checkNotModified, checkNotModified, getContextPath, getDescription, getHeader, getHeaderNames, getHeaderValues, getLocale, getParameter, getParameterMap, getParameterNames, getParameterValues, getRemoteUser, getUserPrincipal, isSecure, isUserInRole`

## Method Details

### setTimeout

void setTimeout(@Nullable Long timeout)
Set the time required for concurrent handling to complete. This property should not be set when concurrent handling is in progress, i.e. when `isAsyncStarted()` is `true`.

Parameters:
  `timeout` - amount of time in milliseconds; `null` means no timeout, i.e. rely on the default timeout of the container.

### addTimeoutHandler

void addTimeoutHandler(Runnable runnable)
Add a handler to invoke when concurrent handling has timed out.

### addErrorHandler

void addErrorHandler(Consumer<Throwable> exceptionHandler)
Add a handler to invoke when an error occurred while concurrent handling of a request.

Since:
  5.0

### addCompletionHandler

void addCompletionHandler(Runnable runnable)
Add a handler to invoke when request processing completes.

### startAsync

void startAsync()
Mark the start of asynchronous request processing so that when the main processing thread exits, the response remains open for further processing in another thread.

Throws:
  `IllegalStateException` - if async processing has completed or is not supported

### isAsyncStarted

boolean isAsyncStarted()
Whether the request is in async mode following a call to `startAsync()`. Returns "false" if asynchronous processing never started, has completed, or the request was dispatched for further processing.

### dispatch

void dispatch()
Dispatch the request to the container in order to resume processing after concurrent execution in an application thread.

### isAsyncComplete

boolean isAsyncComplete()
Whether asynchronous processing has completed.