You'll find below the smallest configuration to reproduce my case.
Actually, it looks more like a Spring JMS problem than a Spring Integration one as the errorHandler is part of the class org.springframework.jms.listener.AbstractMessageLi stenerContainer
That's the only way I found to handle my exceptions with Spring Integration in a synchronous flow (I know we have already discussed this subject before, but I still hope someday to see a more flexible way (per-endpoint strategy) to handle exceptions in SI :-)).
Spring Context
Code:
<int-jms:message-driven-channel-adapter container="jmsListener" channel="channel1" />
<bean id="jmsListener" parent="queueListenerMce">
<property name="destinationName" value="MCEHoldingForexErrorQueue" />
<property name="sessionTransacted" value="true" />
<property name="errorHandler">
<bean class="com.sample.MyErrorHandler" />
</property>
</bean>
<int:publish-subscribe-channel id="channel1" />
<int-stream:stdout-channel-adapter channel="channel1" append-newline="true" />
<int:service-activator input-channel="channel1" output-channel="nullChannel">
<bean class="com.sample.ExceptionThrower" />
</int:service-activator>
com.sample.ExceptionThrower
Code:
public class ExceptionThrower {
public void throwException(String ok) {
throw new RuntimeException("Oh oh...");
}
}
com.sample.MyErrorHandler
Code:
public class MyErrorHandler implements ErrorHandler {
@Override
public void handleError(Throwable arg0) {
System.out.println("Hey, the message failed!");
}
}