| 此版本仍在开发中,尚未被视为稳定版本。对于最新的稳定版本,请使用 Spring Integration 6.3.4! | 
| 此版本仍在开发中,尚未被视为稳定版本。对于最新的稳定版本,请使用 Spring Integration 6.3.4! | 
从版本 6.1 开始,引入了 。
此建议从请求消息中获取一些值,并将其存储在上下文持有者中。
当在 target 上完成执行时,该值从上下文中是明确的。
考虑这个建议的最佳方式类似于编程流程,我们将一些值存储到 a 中,从 target 调用中访问它,然后在执行后清理它。
这需要这些构造函数参数:a 作为值提供者,作为上下文设置回调和作为上下文清理钩子。ContextHolderRequestHandlerAdviceMessageHandlerThreadLocalThreadLocalContextHolderRequestHandlerAdviceFunction<Message<?>, Object>Consumer<Object>Runnable
以下是如何将 a 与 结合使用的示例:ContextHolderRequestHandlerAdviceo.s.i.file.remote.session.DelegatingSessionFactory
@Bean
DelegatingSessionFactory<?> dsf(SessionFactory<?> one, SessionFactory<?> two) {
    return new DelegatingSessionFactory<>(Map.of("one", one, "two", two), null);
}
@Bean
ContextHolderRequestHandlerAdvice contextHolderRequestHandlerAdvice(DelegatingSessionFactory<String> dsf) {
    return new ContextHolderRequestHandlerAdvice(message -> message.getHeaders().get("FACTORY_KEY"),
                                      dsf::setThreadKey, dsf::clearThreadKey);
}
@ServiceActivator(inputChannel = "in", adviceChain = "contextHolderRequestHandlerAdvice")
FtpOutboundGateway ftpOutboundGateway(DelegatingSessionFactory<?> sessionFactory) {
	return new FtpOutboundGateway(sessionFactory, "ls", "payload");
}只需向通道发送消息,并将标头设置为 或 就足够了。
将该标头中的值设置为通过其 .
然后,当执行命令时,根据其 中的值从 中选择适当的委托。
当结果从 生成时,将根据 中的调用清除 中的值。
有关更多信息,请参阅委派 Session Factory。inFACTORY_KEYonetwoContextHolderRequestHandlerAdviceDelegatingSessionFactorysetThreadKeyFtpOutboundGatewaylsSessionFactoryDelegatingSessionFactoryThreadLocalFtpOutboundGatewayThreadLocalDelegatingSessionFactoryclearThreadKey()ContextHolderRequestHandlerAdvice