I'm starting to use Spring integration and I don't know how to resolve this situation if it's possible.
I would like to 'catch' automatically every Exception who could happend in the service activators of my application and send this errors to a dedicated queue. Gateway is not a solution because I need some custom code so I have to use service activator elements if I have correctly understood the principle.
I thought that something like would be ok:
<jms:outbound-channel-adapter channel="errorChannel"
connection-factory="jmsConnectionFactory" destination="oneErrorQueue"/>
That is not working. I don't know if errorChannel is used by spring integration for putting the errors in indeed.
thank you, It seems to work.
I've put the transformer listening to the error-channel of the inbound component starting the flow and it gets the MessagingException when an error happens in service activator. Now the problem is that this error doesn't arrive to my queue. I let you see the code:
<jms:message-driven-channel-adapter
channel="input-channel" concurrent-consumers="1"
max-concurrent-consumers="3" connection-factory="jmsConnectionFactory"
transaction-manager="jtaTransactionManager" destination="myQueue" error-channel="myErrorChannel"/>
<transformer input-channel="myErrorChannel" output-channel="create-error-channel" ref="errorTransporter" method="transform"/>
<jms:outbound-channel-adapter channel="create-error-channel"
connection-factory="jmsConnectionFactory" destination="creationErrorQueue" extract-payload="true"/>
...
And the transformer:
public class ErrorTransporter {
@Transformer
public Message<CreateCustomerOrder> transform(MessagingException exception) {
return (Message<CreateCustomerOrder>) exception.getFailedMessage();
}
}
Thanks in advance for helping!