2014-09-29 88 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