Spring Integration异常始终未达到errorChannel

时间:2018-12-07 13:49:17

标签: spring spring-integration spring-io

<bean id="triggerFileScanner" class="abc.xyz">
    <property name="triggerFile" value="value1" />
</bean>

<int-file:inbound-channel-adapter id="fileInbound" directory="somepath/directory" filter="acceptallFilter" scanner="triggerFileScanner"
    auto-startup="true" channel="fileChannel">
    <int:poller max-messages-per-poll="10" time-unit="SECONDS" fixed-delay="10" receive-timeout="30000" />
</int-file:inbound-channel-adapter> 

<int:header-enricher id="headerEnricher" input-channel="fileChannel" output-channel="processChannel">
    <int:header name="flowName" value="Name" />
    <int:header name="flowID" method="uuidgenerate" ref="headerEnricherBean" />
    <int:header name="flowStartTime" method="generateTimeString" ref="headerEnricherBean"></int:header>
    <int:header name="fileName" method="deriveFileName" ref="headerEnricherBean" />
</int:header-enricher>

<int:channel id="processChannel">
    <int:interceptors>
        <int:wire-tap channel="copyChannel" id="copyTap" />
    </int:interceptors>
</int:channel>
<int:channel id="copyChannel"></int:channel>

<int-file:outbound-channel-adapter id="fileCopier" channel="copyChannel" delete-source-files="false" filename-generator="dateSuffixFileNameGenerator"
    directory="copy.path">
</int-file:outbound-channel-adapter>


<int:filter id="formatcheckFilter" ref="formatValidator" method="validateFile" input-channel="processChannel" output-channel="processDataChannel"
    discard-channel="errorChannel" auto-startup="true">
</int:filter>

<int:service-activator id="converter" input-channel="processDataChannel" method="convert" ref="fileToQueryConverter" auto-startup="true"
    output-channel="impChannel" />

<bean id="importer" class="testbean.import">
    <property name="errorpath" value="path1" />
    <property name="sourcepath" value="path2" />
</bean>

<int:service-activator input-channel="impChannel" ref="impeximporter" id="importProcess" method="import" auto-startup="true"
    output-channel="archiveChannel" />

<int:channel id="archiveChannel">
    <int:interceptors>
        <int:wire-tap channel="logChannel" id="completionLogger" />
    </int:interceptors>
</int:channel>

<int:channel id="logChannel"></int:channel>

<int-file:outbound-channel-adapter id="fileArchiver" channel="archiveChannel" delete-source-files="true" filename-generator="dateSuffixFileNameGenerator"
    directory="archive.path">
</int-file:outbound-channel-adapter>

<int:service-activator id="flowLogger" input-channel="logChannel" ref="messageLogger" method="logMessage">
</int:service-activator>

有时服务激活器的异常将进入错误通道,但是有时却不会。

我的错误通道定义如下:

<int:channel id="errorChannel" />

<bean id="exceptionHandler" class=my.custom.ExceptionHandler">
</bean>
<int:service-activator id="errorLogger" input-channel="errorChannel" method="handle" ref="exceptionHandler">
</int:service-activator>

我在许多集成中都使用了这个错误通道,在我的服务激活器中,我只是在抛出throw Exception(“ Message”)

0 个答案:

没有答案