我已经用Spring集成定义了一个很好的流,在标称情况下,它可以按我所希望的那样工作。
但是,我还没有找到一种方法来定义处理错误的行为(即将输入行标记为失败)
下面是我得到的错误:
[ask-scheduler-2] cMessagingTemplate$TemporaryReplyChannel : Reply message received but the receiving thread has exited due to an exception while sending the request message:ErrorMessage [payload=org.springframework.messaging.MessageHandlingException: error occurred in message handler [outboundGateway]; nested exception is...
以下是我的流程配置(简化):
@Configuration
@EnableIntegration
public class IntegrationConfig {
@Autowired
private DataSource dataSource;
@Bean
public IntegrationFlow mainFlow() {
return IntegrationFlows.from(jdbcMessageSource(),
c -> c.poller(Pollers.fixedRate(5000)
.transactional(transactionManager())))
.split()
.enrich(e -> e
.requestChannel(subChannel())
.requestPayload(Message::getPayload)
.propertyExpression("fooId", "payload.id"))
.handle(barHandler())
.get();
}
@Bean
public IntegrationFlow enricherFlow() {
return IntegrationFlows.from(subChannel())
.handle(outboundGateway())
.get();
}
@Bean
public MessageChannel subChannel() {
return new DirectChannel();
}
@Bean
public MessageSource<Object> jdbcMessageSource() {
return new JdbcPollingChannelAdapter(this.dataSource,
"select * from FOO");
}
@Bean
public JdbcOutboundGateway outboundGateway() {
...
}
@Bean
public JdbcMessageHandler barHandler() {
return new JdbcMessageHandler(dataSource,
"INSERT INTO BAR ...");
}
@Bean
public PlatformTransactionManager transactionManager() {
return new DataSourceTransactionManager(dataSource);
}
}
我本以为我可以在默认的errorChannel上获得错误,并在那里执行必要的任务,但我还没有找到实现这一点的方法。
非常感谢您的任何想法和帮助!