У меня есть хороший поток, определенный с помощью Spring Integration, в номинальном случае он работает так, как я хочу.
Однако я еще не нашел способа определить поведение для обработки ошибки (т.е. пометить входную строку как неудачную).
Вот ошибка, которую я получаю:
[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() {
//noinspection unchecked
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 по умолчанию и выполнить там необходимые задачи, но я не нашел способа заставить эту работу.
Любые идеи и помощь приветствуются!