【问题标题】:spring integration: inbound channel adapter. catch an exceptionspring 集成:入站通道适配器。捕捉异常
【发布时间】:2016-01-08 13:47:09
【问题描述】:

我实现了一个 sftp-inbound-channel-adapter,当处理异常时,我应该显示一条自定义消息。

我试过了:

<int-sftp:inbound-channel-adapter id="sftpInbondAdapter"
    auto-startup="true" channel="receiveChannel" session-factory="sftpSessionFactory"
    local-directory="file:${directory.files.local}" remote-directory="${directory.files.remote}"
    auto-create-local-directory="true" delete-remote-files="true"  
    filename-pattern="*.txt" >
    <int:poller fixed-delay="${sftp.interval.request}"
        max-messages-per-poll="-1" />

<int-sftp:request-handler-advice-chain>

<bean: class="org.springframework.integration.handler.advice.ExpressionEvaluatingRequestHandlerAdvice">

<property name="onSuccessExpression" value="payload" />
<property name="successChannel" ref="afterSuccessDeleteChannel" />
<property name="onFailureExpression" value="payload.renameTo(new java.io.File(payload.absolutePath + '.failed.to.send'))" />
<property name="failureChannel" ref="afterFailRenameChannel" />
</bean>
</int-sftp:request-handler-advice-chain>

但是一个元素

&lt;int-sftp:request-handler-advice-chain&gt;

不被接受。你能解释一下另一种解决方案吗?

【问题讨论】:

    标签: spring-integration


    【解决方案1】:

    请求处理程序建议在某些下游组件上进行,而不是入站通道适配器。

    您可以将error-channel 添加到&lt;poller/&gt; 元素。发送到错误通道的消息将是一个ErrorMessage,异常作为有效负载。如果是下游流的异常,则有效负载将是具有failedMessagecause 属性的MessagingException

    添加一些组件以使用错误消息。

    【讨论】:

      猜你喜欢
      • 2015-07-11
      • 2014-12-07
      • 2023-03-21
      • 1970-01-01
      • 1970-01-01
      • 2011-08-29
      • 1970-01-01
      • 2014-05-31
      • 2013-02-02
      相关资源
      最近更新 更多