Hi Oleg and thank you for your reply.
Here's one of the many use cases where I'd need some error handling. I provided a sample of my XML configuration below (some channels are defined in other files so don't bother looking for them).
There is a succession of endpoints, and for each endpoint (or channel), I would have liked to configure how to handle the errors.
All my service activators may throw exceptions: depending on the service activator (and possibly, but not essentially, depending on the exception), I would like to send an email; for others, route the message to another channel or simply drop the message. Same thing for my customized splitters and transformers.
All these behaviours could be quickly implemented if there was a configurable "error-channel" attribute for each of these endpoints.
Note that I'm working in a synchronized flow here. But even in an unsynchronized flow, more customization would really be nice to handle errors differently depending on where and why the message failed to be processed.
Any solution I would have missed to do this?
Code:
<int-file:inbound-channel-adapter channel="fileChannel" directory="/Tests" filename-pattern=".*\.xml" auto-startup="false">
<int:poller>
<int:interval-trigger interval="1000" />
</int:poller>
</int-file:inbound-channel-adapter>
<int:channel id="fileChannel" />
<int-file:file-to-string-transformer input-channel="fileChannel" output-channel="fileContentChannel" />
<int:channel id="fileContentChannel" />
<int:header-enricher input-channel="fileContentChannel" output-channel="headersChannel">
<int:header name="rawInputMessage" expression="payload" />
<int:header name="auditProcess" value="EPS" />
</int:header-enricher>
<int:channel id="headersChannel" />
<int:header-value-router input-channel="headersChannel" header-name="technicalRedelivery" default-output-channel="noRedeliveryChannel">
<int:mapping value="true" channel="duplicateChannel" />
</int:header-value-router>
<int:channel id="noRedeliveryChannel" />
<int:chain input-channel="noRedeliveryChannel" output-channel="endOfChainChannel">
<int:service-activator ref="trnGenerator" method="generateTrni" />
<int:service-activator ref="auditMessagePersistence" />
<int-xml:unmarshalling-transformer unmarshaller="JaxbMarshaller" />
<int:splitter method="splitMessage">
<bean class="com.RuleSolverFlowDetailsSplitter">
<property name="dataSource" value="DKG" />
<property name="ruleSolverTreeName" value="DKG" />
</bean>
</int:splitter>
<int:service-activator ref="trnGenerator" method="generateTrno" />
</int:chain>
<int:channel id="endOfChainChannel">
<int:interceptors>
<int:wire-tap channel="auditPendingChannel"/>
</int:interceptors>
</int:channel>
<!-- To be completed... -->
<int:bridge input-channel="endOfChainChannel" output-channel="nullChannel" />
<!-- CHANNELS ASIDE -->
<int:channel id="duplicateChannel" />
<int-xml:unmarshalling-transformer unmarshaller="JaxbMarshaller" input-channel="duplicateChannel" output-channel="auditCheckDuplicateChannel"/>
<!-- BEANS DEFINITIONS -->
<bean id="trnGenerator" parent="abstractTrnGeneratorServices">
<property name="sequenceName" value="EPS" />
<property name="prefix" value="EPS" />
</bean>
Thank you!