I try to handle the exceptions that happen in my spring integration flow.
The flow is as follows:
source -> split -> handle -> handle
My source gives a List of objects as payload. The split emits one element at a time.
The 1st handler encounters exception. I was expecting that since the exception is being published to the error channel configured in below samples, the other elements in the list will continue to be emitted. But after the first exception the flow stops!!! Is there a configuration that I am missing ?
@Bean
public IntegrationFlow pubSubFlow(PublishSubscribeChannel publishSubscribeChannel,
@Qualifier("myMessagePublishingErrorHandler") MessagePublishingErrorHandler messagePublishingErrorHandler) {
return flow -> flow
.channel(publishSubscribeChannel)
.publishSubscribeChannel(config -> config
.subscribe(f1 -> f1
.split()
.handle("action", "act")
.handle(m1 -> System.out.println(">>>" + m1)))
.subscribe(f1 -> f1
.split()
.handle(m1 -> System.out.println("<<<" + m1)))
.errorHandler(messagePublishingErrorHandler));
}
The error handler:
@Bean
public MessagePublishingErrorHandler myMessagePublishingErrorHandler(@Qualifier("appErrorChannel") DirectChannel directChannel) {
MessagePublishingErrorHandler messagePublishingErrorHandler = new MessagePublishingErrorHandler();
messagePublishingErrorHandler.setDefaultErrorChannel(directChannel);
return messagePublishingErrorHandler;
}
@Bean
public DirectChannel appErrorChannel() {
return new DirectChannel();
}
@Bean
public IntegrationFlow errorFlow(@Qualifier("appErrorChannel") DirectChannel directChannel) {
return IntegrationFlows.from(directChannel).handle(System.out::println).get();
}