Spring集成RecipientListRouter不';不能创建多个有效负载
请任何人帮我解决这个问题,我按照文档建议配置了我的ReceipEntListRouter:Spring集成RecipientListRouter不';不能创建多个有效负载,spring,spring-integration,integration,Spring,Spring Integration,Integration,请任何人帮我解决这个问题,我按照文档建议配置了我的ReceipEntListRouter: @Bean public IntegrationFlow routerFlow() { return IntegrationFlows.from(CHANNEL_INPUT) .routeToRecipients(r -> r .applySequence(true)
@Bean
public IntegrationFlow routerFlow() {
return IntegrationFlows.from(CHANNEL_INPUT)
.routeToRecipients(r -> r
.applySequence(true)
.ignoreSendFailures(true)
.recipient(CHANNEL_OUTPUT_1)
.recipient(CHANNEL_OUTPUT_2)
.sendTimeout(1_234L))
.get();
}
@ServiceActivator(inputChannel = CHANNEL_OUTPUT_1, outputChannel = CHANNEL_END)
public Object foo(Message<?> message) {
message.gePayload();
// processing1() ...
}
@ServiceActivator(inputChannel = CHANNEL_OUTPUT_2, outputChannel = CHANNEL_END)
public Object bar(Message<?> message) {
message.gePayload();
// processing2() ...
}
其中,foo激活器输入端的有效载荷-2等于有效载荷-1,杆激活器输入端的有效载荷-3等于有效载荷-1
但实际的工作流程是:
foo激活器输入端的有效载荷-2等于有效载荷-1,但杆激活器输入端的有效载荷-3等于foo激活器输出端的有效载荷-2消息
调试后,我注意到message.getHeader()不一样(它实际上包含“sequenceNumber”和“sequenceSize”),但是对于message.getPayload是如上所述的,当消息是不可变的时,负载不是(除非它是不可变的对象,如字符串) 如果您在service1中对有效负载进行了变异,那么在service2中就会看到这种变异
如果不想让service2看到变异,则需要在变异前克隆/复制有效负载。框架不负责决定克隆或复制有效负载:,
CHANNEL_INPUT(payload-1) |----> CHANNEL_OUTPUT_1(payload-2)
|----> CHANNEL_OUTPUT_2(payload-3)
it seems like this is the actual workflow
CHANNEL_INPUT(payload-1)----> CHANNEL_OUTPUT_1(payload-2)----> CHANNEL_OUTPUT_2(payload-3)