Murat Goksel
Murat Goksel

Reputation: 47

How can I direct exception to a custom error channel in Spring Integration?

I set up a custom Hot Folder in SAP Commerce (hybris) with a custom error channel, but I can't get Spring to call my custom error handler NviMediaErrorHandler. This the set-up in hot-folder-spring.xml file.

<!-- General set-up -->
<int:channel id="nviMediaErrorChannel"/>

<int:service-activator ref="nviMediaErrorHandler" input-channel="nviMediaErrorChannel" method="onError"/>

<bean id="nviMediaErrorHandler" class="com.nvi.core.data.hotfolder.media.task.ErrorHandler">
    <property name="cleanupHelper" ref="nviMediaCleanupHelper"/>
</bean>

<bean id="nviMediaCleanupHelper" class="com.nvi.core.data.hotfolder.media.task.NviMediaCleanupHelper"/>

<bean id="mediaDirectoryNvi" class="java.lang.String">
    <constructor-arg value="#{baseDirectory}/${tenantId}/nvi/media"/>
</bean>


<!-- Image file import process -->
<!-- 1) Scans a directory in a configurable interval and sends files to a configured channel -->
<file:inbound-channel-adapter id="mediaFilesNvi" directory="#{mediaDirectoryNvi}"
                              filename-regex="^\d+(_\d+)?\.(png|jpe?g)" comparator="fileOrderComparator"
                              prevent-duplicates="false">
    <int:poller fixed-rate="1000"/>
</file:inbound-channel-adapter>

<!-- 2) Move file to processing/ directory and set up header -->
<file:outbound-gateway request-channel="mediaFilesNvi" reply-channel="mediaFilesNviProcess"
                       directory="#{mediaDirectoryNvi}/processing" delete-source-files="true"/>

<int:service-activator input-channel="mediaFilesNviProcess" output-channel="mediaHeaderSetup"
                       ref="mediaHeaderSetupTask" method="execute"/>

<bean id="mediaHeaderSetupTask" class="com.nvi.core.data.hotfolder.media.task.HeaderSetupTask">
    <property name="catalogs">
        <util:list id="catalogList" value-type="java.lang.String">
            <value>ambestProductCatalog</value>
            <value>egwProductCatalog</value>
            <value>moProductCatalog</value>
            <value>walmartProductCatalog</value>
        </util:list>
    </property>
</bean>

<!-- 3) Import image file -->
<int:service-activator input-channel="mediaHeaderSetup" output-channel="mediaFileImport"
                       ref="productImageImportTask" method="execute"/>

<bean id="productImageImportTask" class="com.nvi.core.data.hotfolder.media.task.ProductImageImportTask"/>

<!-- Clean up -->
<int:service-activator input-channel="mediaFileImport" ref="fileCleanupTask" method="execute"/>

<bean id="fileCleanupTask" class="com.nvi.core.data.hotfolder.media.task.CleanupTask">
    <property name="cleanupHelper" ref="nviMediaCleanupHelper"/>
</bean>

I need errors to go into nviMediaErrorHandler and call com.nvi.core.data.hotfolder.media.task.ErrorHandler in particular, not the SAP Commerce's out-of-the-box ErrorHandler. Any help is appreciated. Thanks!

Upvotes: 1

Views: 924

Answers (1)

Gary Russell
Gary Russell

Reputation: 174554

<int:poller fixed-rate="1000" error-channel="nviMediaErrorHandler"/>

Upvotes: 1

Related Questions