2014-09-29 90 views
0

我試圖從ChennelInterceptor拋出一些異常。但它沒有發送消息到我定義的ErrrorChannel。errorChannel無法識別拋出異常表單後ChannelInterceptor

下面的代碼段。從com.abc.SomeValidationInterceptor.And

<int-file:inbound-channel-adapter id="fileInBound" 
      channel="fileProcessingChannel" 
      directory="${file.processing.folder}" 
      prevent-duplicates="true" 
      filename-pattern="*.txt"> 
</int-file:inbound-channel-adapter> 
<int:channel id="fileProcessingChannel"> 
    <int:queue/> 
</int:channel> 
<!--Setting the Error Channel --> 
<int:header-enricher input-channel="inputchannel" output-channel="testChannel"> 
    <int:error-channel ref="myErrorChannel" overwrite="true"></int:error-channel> 
</int:header-enricher> 

<!-- Accepts only the File data Type --> 
<int:channel id="testChannel" > 
    <int:interceptors> 
     <bean class="com.abc.SomeValidationInterceptor"></bean> 
    </int:interceptors> 
</int:channel> 

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

<int:service-activator input-channel="myErrorChannel" output-channel="nullChannel"> 
     <bean class="com.abc.MyErrorHandlerEndpoint"></bean>  
</int:service-activator> 

上午投擲例外即MessagingException我希望能達到myErrorChannel但鼻涕達到myErrorChannel。

任何想法爲什麼它不工作。提前感謝。

回答

1

它不這樣工作。除非是非常特殊的情況,否則通常不應該自己操縱errorChannel頭。

你如何獲取消息到inputChannel

一般來說,你應該使用某種類型的網關,並在其上聲明error-channel;讓框架處理標題;該例外被網關捕獲,並且ErrorMessage適當地路由。

同樣,可以在輪詢端點的輪詢器上定義error-channel

+0

查看更多信息參考手冊:http://docs.spring.io/spring-integration/docs/latest-ga/reference/html/configuration.html#namespace-errorhandler – 2014-09-29 16:05:18

+0

謝謝Gary.Actually我正在處理文件格式文件:inbound-channel-adater.I已更新我的原始POST中的配置信息。 – Annavi 2014-09-29 17:25:14

+0

我在Poller中使用了錯誤通道 – Annavi 2014-09-29 18:32:42