Моя программа делает следующее на высоком уровне
Task 1
get the data from the System X
the Java DSL split
post the data to the System Y
post the reply data to the X
the Java DSL aggregate
Task 2
get the data from the System X
the Java DSL split
post the data to the System Y
post the reply data to the X
the Java DSL aggregate
...
Проблема в том, что когда одна post the data to the System Y
подзадача выходит из строя, сообщение об ошибке правильно отправляется обратно в Систему X, но после этого любые другие подзадачи или задачи не выполняются.
Мой обработчик ошибок делает следующее:
...
Message<String> newMessage = MessageBuilder.withPayload("error occurred")
.copyHeadersIfAbsent(message.getPayload().getFailedMessage().getHeaders()).build();
...
Set some extra headers etc.
...
return newMessage;
В чем может быть проблема?
Редактировать:
Я отлаживал Spring Integration. В случае возникновения ошибки в метод AbstractCorrelatingMessageHandler.handleMessageInternal
поступает только первое сообщение об ошибке. Другие успешные и неудачные сообщения в метод не поступают.
Если ошибок нет, все сообщения поступают в метод и, наконец, группа освобождается.
Что могло быть не так в моей программе?
Изменить 2:
Это работает:
Добавлен advice
для Http.outboundGateway
:
.handle(Http.outboundGateway(...,
c -> c.advice(myAdvice()))
и фасоль myAdvice
@Bean
private Advice myAdvice() {
return new MyAdvice();
}
и MyAdvice
класс
public class MyAdvice<T> extends AbstractRequestHandlerAdvice {
@SuppressWarnings("unchecked")
@Override
protected Object doInvoke(final ExecutionCallback callback, final Object target, final Message<?> message)
throws Exception {
...
try {
result = (MessageBuilder<T>) callback.execute();
} catch (final MessageHandlingException e) {
take the exception cause for the new payload
}
return new message with the old headers and replyChannel header and result.payload or the exception cause as a payload
}
}