为了账号安全,请及时绑定邮箱和手机立即绑定

如何从 jdbc-inbound-channel-adapter 捕获异常?

如何从 jdbc-inbound-channel-adapter 捕获异常?

饮歌长啸 2022-05-25 10:49:22
是否可以从jdbc-inbound-channel-adapter(例如查询执行期间的数据库问题)捕获异常?例如,http-outbound-gateway可以使用带有error-handler属性声明的错误处理程序。谢谢你的建议。
查看完整描述

1 回答

?
慕容708150

TA贡献1831条经验 获得超4个赞

Ajdbc-inbound-channel-adapter完全基于“硬”轮询逻辑JdbcPollingChannelAdapter及其包装器。SourcePollingChannelAdapter


我很确定您已经<poller>为提到的jdbc-inbound-channel-adapter或全局提供了配置。


那个有这个选项:


   <xsd:attribute name="error-channel" type="xsd:string">

        <xsd:annotation>

            <xsd:documentation><![CDATA[

                Identifies channel that error messages will be sent to if a failure occurs in this

                poller's invocation. To completely suppress Exceptions, provide a

                reference to the "nullChannel" here.

            ]]></xsd:documentation>

        </xsd:annotation>

    </xsd:attribute>

因此,当轮询 DB 期间出现一些错误时,它将被包装到 anErrorMessage并发送到已配置的error-channel. 如果未提供,则将使用全局errorChannelbean。


有关详细信息,请参阅参考手册中的错误处理章节:https ://docs.spring.io/spring-integration/docs/current/reference/html/configuration.html#namespace-errorhandler


查看完整回答
反对 回复 2022-05-25
  • 1 回答
  • 0 关注
  • 144 浏览

添加回答

举报

0/150
提交
取消
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号