栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

在Spring集成中,如何捕获不同的异常?

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

在Spring集成中,如何捕获不同的异常?

实际上

<tcp-connection-event-inbound-channel-adapter>
发送给
channel
一个
Message
TcpConnectionExceptionEvent
(在你的情况下)的
payload

因此,您的订阅者(您的

TcpErrorHandler
)可以接受
TcpConnectionExceptionEvent
作为方法参数。

在该方法中,您可以进行进一步的逻辑处理,例如从中提取原始

Exception
内容
IntegrationEvent

使用

IP
时模块中有多个位置
TcpConnectionSupport.publishConnectionExceptionEvent

如果您说不了解

time outexception
,那么如果您共享此事的日志,那就太好了。我不知道我们做哪个地方不
try...catch
SocketTimeoutException

更新

<int-ip:tcp-connection-event-inbound-channel-adapter channel="events"     event-types="org.springframework.integration.ip.tcp.connection.TcpConnectionExceptionEvent"/><service-activator input-channel="events" ref="tcpErrorHandler"/>

public class TcpErrorHandler {   public void onException(TcpConnectionExceptionEvent event) {       System.out.println("Exception!!! ");       event.getCause();       ....   }}

这应该工作。

更新2

根据您的代码:

try {   super.send(message);}catch (Exception e) {    System.out.println("catched_send_exception");}

您是否认为在其中窒息异常是不好的?

从另一面看:确定要调用您的日志时,您介意

DEBUG
为该
org.springframework.integration
类别打开日志记录级别并在此处共享日志
tcpErrorHandler
吗?

从另一侧尝试

<int-ip:tcp-connection-event-inbound-channel-adapter>
完全没有
event-types
。我的意思是让我们看看它是否可以处理任何内容
IpIntegrationEvent



转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/428853.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号