spring 集成 dsl 流变量以在流中存储和检索
spring integration dsl flow variables to store & retrieve with in the flow
我正在寻找一些流变量,我需要在其中存储 orderId、customerId 和流中收到的其他响应等值,以便我可以在流的后面部分使用它们来编写业务逻辑。
.handle(outboundGateway("localhost:8080/order?orderId={orderId}")
.uriVariable("orderId", m -> m.getPayload())
.httpMethod(HttpMethod.GET)
.expectedResponseType(Order.class)
.handle(outboundGateway("localhost:8080/orderDetails?orderId={orderId}")
.uriVariable("orderId", m -> m.getPayload())
.httpMethod(HttpMethod.GET)
.expectedResponseType(OrderDetails.class)
.handle(outboundGateway("localhost:8080/customer?customerId={customerId}")
.uriVariable("customerId", m -> ((OrderDetails)m.getPayload()).getCustomerId())
.httpMethod(HttpMethod.GET)
.expectedResponseType(Customer.class)
.handle(outboundGateway("localhost:8080/customerAddress?addressId={addressId}")
.uriVariable("addressId", m -> ((Customer)m.getPayload()).getAdderssId)
.httpMethod(HttpMethod.GET)
.expectedResponseType(CustomerAddress.class)
.handle((p, h) -> somebusinesslogic)
流程中没有state
这样的抽象。好吧,本质上,运行时根本没有流程。 IntegrationFlow
只是一个逻辑容器。更多内容最好将 Spring 集成解决方案视为完全 stateless
(除非我们谈论 aggregator
)。
然而,有一个解决方案适合您,如将任何额外的必需信息连同其 headers 中的消息一起传输。这样你在 .handle()
之前使用 .enrichHeaders()
并根据 ServiceActivator
的传播性质,请求 headers 正在复制到回复消息,因此,它们在下一个中可用流程步骤。
我正在寻找一些流变量,我需要在其中存储 orderId、customerId 和流中收到的其他响应等值,以便我可以在流的后面部分使用它们来编写业务逻辑。
.handle(outboundGateway("localhost:8080/order?orderId={orderId}")
.uriVariable("orderId", m -> m.getPayload())
.httpMethod(HttpMethod.GET)
.expectedResponseType(Order.class)
.handle(outboundGateway("localhost:8080/orderDetails?orderId={orderId}")
.uriVariable("orderId", m -> m.getPayload())
.httpMethod(HttpMethod.GET)
.expectedResponseType(OrderDetails.class)
.handle(outboundGateway("localhost:8080/customer?customerId={customerId}")
.uriVariable("customerId", m -> ((OrderDetails)m.getPayload()).getCustomerId())
.httpMethod(HttpMethod.GET)
.expectedResponseType(Customer.class)
.handle(outboundGateway("localhost:8080/customerAddress?addressId={addressId}")
.uriVariable("addressId", m -> ((Customer)m.getPayload()).getAdderssId)
.httpMethod(HttpMethod.GET)
.expectedResponseType(CustomerAddress.class)
.handle((p, h) -> somebusinesslogic)
流程中没有state
这样的抽象。好吧,本质上,运行时根本没有流程。 IntegrationFlow
只是一个逻辑容器。更多内容最好将 Spring 集成解决方案视为完全 stateless
(除非我们谈论 aggregator
)。
然而,有一个解决方案适合您,如将任何额外的必需信息连同其 headers 中的消息一起传输。这样你在 .handle()
之前使用 .enrichHeaders()
并根据 ServiceActivator
的传播性质,请求 headers 正在复制到回复消息,因此,它们在下一个中可用流程步骤。