Hi!
I've been trying out Spring Integration a bit, so far with unexpected amounts of success, but when it comes to handling exceptions I'm stumped.
I have a JMS queue which takes requests, the service does stuff and the result is posted to another queue, defined in the request's JMSRepyTo header. This works fine, but if an exception occurs I'd like some error message to be sent on the reply queue and that I've had no luck achieving.
This is the configuration I have at the moment:
and this is the ErrorHandler:Code:<!-- Channels --> <si:channel id="inputChannel"/> <si:chain input-channel="inputChannel" output-channel="outputChannel"> <si:header-enricher error-channel="errorChannel"/> <si:filter ref="messageRouter" method="reroute"/> <si:transformer ref="payloadExtractor" method="extract"/> <si:transformer ref="OXMapper" method="unmarshall"/> <si:service-activator ref="messageEndpoint" method="doStuff"/> <si:transformer ref="OXMapper" method="marshall"/> <si:transformer ref="payloadExtractor" method="soapify"/> </si:chain> <si-jms:message-driven-channel-adapter channel="inputChannel" connection-factory="connectionFactory"/> <si:channel id="outputChannel"/> <si-jms:outbound-channel-adapter channel="outputChannel" jms-template="jmsTemplate" /> <si:channel id="errorChannel"/> <si:chain input-channel="errorChannel" output-channel="outputChannel"> <si:transformer ref="errorHandler" method="handleMessage"/> </si:chain> <bean id="jmsTemplate" class="org.springframework.jms.core.JmsTemplate"> <property name="connectionFactory" ref="connectionFactory"/> <property name="defaultDestinationName" value="DEFAULTOUTPUTQUEUE"/> </bean> <!-- Classes --> <!-- changes jmsTemplate's defaultDestinationName to queue in message's JMSReplyTo header --> <bean id="messageRouter" class="test.MessageRouter"> <property name="jmsTemplate" ref="jmsTemplate"/> </bean> <!-- extracts/wraps payload from/in SOAP message --> <bean id="payloadExtractor" class="test.PayloadTransformer"> <property name="jmsTemplate" ref="jmsTemplate"/> </bean> <!-- unmarshalls/marshalls objects from/to XML --> <bean id="OXMapper" class="test.OXMapper"> <property name="jmsTemplate" ref="jmsTemplate"/> <property name="mapper" ref="testMapper"/> </bean> <!-- does stuff --> <bean id="messageEndpoint" class="test.MessageEndpoint"> <property name="jmsTemplate" ref="jmsTemplate"/> <property name="localityService" ref="localityService"/> </bean> <!-- is supposed to handle error messages --> <bean id="errorHandler" class="test.ErrorHandler"> <property name="jmsTemplate" ref="jmsTemplate"/> </bean>
When I throw an exception in the input chain nothing is printed and no reply is sent to any queue.Code:public class ErrorHandler extends MessageSender { @Transformer public String handleMessage(Message errorMessage) { System.out.println("Here!"); return "Something happened!"; } }
Please help me! What am I doing wrong?


Reply With Quote