gpt4 book ai didi

spring-integration - spring 集成 : inbound channel adapter. 捕获异常

转载 作者:行者123 更新时间:2023-12-04 07:52:55 25 4
gpt4 key购买 nike

我实现了一个 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>

但是一个元素
<int-sftp:request-handler-advice-chain>
不被接受。你能解释另一种解决方案吗?

最佳答案

请求处理程序建议在某个下游组件上运行,而不是在入站 channel 适配器上。

您可以添加 error-channel<poller/>元素。发送到错误 channel 的消息将是 ErrorMessage除了作为有效载荷。如果是下游流的异常,则有效载荷将为 MessagingExceptionfailedMessagecause特性。

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

关于spring-integration - spring 集成 : inbound channel adapter. 捕获异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34678588/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com