如何在Spring Integration Flow中的threadlocal中注入变量

问题描述 投票:0回答:2

我需要在Spring集成流程中将callContext对象作为Local线程注入。应该提取n在callContext对象中设置的jms标头中接收到的traceId,以便将其打印到在项目级别配置的日志中。]

IntegrationFlows.from(Jms.messageDrivenChannelAdapter(connectionFactory).destination(topicName))
.log(INFO, m-> “message received for: + ((Order)m.getPayload()).getOrderId())
.handle(orderService)
.get();

我需要在Spring集成流程中将callContext对象作为Local线程注入。应提取n在callContext对象中设置的jms标头中接收到的traceId,以便将其打印出来...

spring-integration spring-integration-dsl
2个回答
0
投票

您可以在orderService中进行操作,或在其之前添加其他服务。


0
投票

我想说的是Function表示log()运算符,它使您可以完全控制要登录的消息。当然,也要避免使用ThreadLocal的开销。但是,如果您仍然想使用它,我建议在.wireTap()之前建议使用log(),这样您就可以在ThreadLocal(MDC?)中存储一个值,而不会影响主流。

© www.soinside.com 2019 - 2024. All rights reserved.