public class ContextDecorator extends Object implements org.springframework.core.task.TaskDecorator
https://stackoverflow.com/questions/23732089/how-to-enable-request-scope-in-async-task-executor
传递:RequestAttributes and MDC and SecurityContext
Modifier and Type | Field and Description |
---|---|
protected AsyncProperties |
asyncProperties |
Constructor and Description |
---|
ContextDecorator() |
Modifier and Type | Method and Description |
---|---|
Runnable |
decorate(Runnable runnable) |
static void |
enableServletAsyncContext(org.springframework.web.context.request.ServletRequestAttributes context,
AsyncProperties asyncProperties)
启用 ServletAsyncContext,异步上下文最长生命周期(最大阻塞父线程多久)
|
protected AsyncProperties asyncProperties
public Runnable decorate(Runnable runnable)
decorate
in interface org.springframework.core.task.TaskDecorator
public static void enableServletAsyncContext(org.springframework.web.context.request.ServletRequestAttributes context, AsyncProperties asyncProperties)
用于阻塞父线程 Servlet 的关闭(调用 destroy() 方法),导致子线程获取的上下文为空
context
- 父线程上下文asyncProperties
- 异步属性配置Copyright © 2022 Pivotal Software, Inc.. All rights reserved.