spring - 消息处理在 Spring 集成中随机暂停/暂停一小段时间
问题描述
我有一个使用 spring 集成框架进行消息处理的应用程序(网关 -> 转换 -> 服务激活器)。我面临的问题之一是处理消息有相当长的延迟,从几毫秒到几秒不等。滞后并不一致,似乎消息被搁置并一次处理。
我尝试使用 YourKit 分析应用程序,但找不到任何死锁或阻塞的线程。打开 org.springframework.integration 的调试日志也没有提供太多信息。这是spring集成xml:
<int:gateway service-interface="com.test.MessageGateway"
id="msggateway" default-request-channel="msginputchannel" />
<int:channel id="msginputchannel">
<int:queue capacity="5000" />
</int:channel>
<int:bridge id="msginputbridge" input-channel="msginputchannel" output-channel="msgchannel">
<int:poller fixed-delay="100"/>
</int:bridge>
<int:channel id="msgchannel">
<int:queue capacity="5000" />
</int:channel>
<int:transformer input-channel="msgchannel"
output-channel="msgPubSubchannel" id="msgtransformer" ref="msgserializer" method="serialzeTo" >
<int:poller fixed-delay="100" />
</int:transformer>
<int:publish-subscribe-channel id="msgPubSubchannel" />
<int:bridge id="msgQueueSystembridge" input-channel="msgPubSubchannel" output-channel="msgQueueSystemqueuechannel"/>
<int:channel id="msgQueueSystemqueuechannel">
<int:queue capacity="5000"/>
</int:channel>
<int:service-activator id="msgQueueSystempublisher" ref="msgQueueSystemadapter" input-channel="msgQueueSystemqueuechannel" method="publish" >
<int:poller fixed-delay="100"/>
</int:service-activator>
<int:bridge id="msgbridge" input-channel="msgPubSubchannel" output-channel="msgFileSystemchannel"/>
<int:channel id="msgFileSystemchannel">
<int:queue capacity="5000"/>
</int:channel>
<int:service-activator id="msgfilewriter" ref="msgadapter" input-channel="msgFileSystemchannel" method="publish" >
<int:poller fixed-delay="100"/>
</int:service-activator>
关于如何进行调试的任何指示?
解决方案
您使用了很多QueueChannel
s 并且它们的所有轮询任务都基于TaskSheduler
线程池的默认设置10
。所以,对于你来说,所有任务只共享这 10 个线程确实可能是一个瓶颈。
您可能会考虑不要在两者之间使用太多队列:我看不出有理由在流程中的所有步骤上排队。
另一方面,您可以使用集成spring.integration.taskScheduler.poolSize
属性将该池大小增加到所需的数量:https ://docs.spring.io/spring-integration/docs/current/reference/html/whats-new.html#x51.-全局属性
推荐阅读
- c# - 关闭窗口时调试不会停止
- c++ - 当初始化列表时参数不可用时如何初始化成员对象?
- npm - 无法通过带有 X11 转发的“npm start”运行电子
- dart - 尝试使用 InheritedWidget 但获取 Null
- mongodb - 未找到从 MongoDB 2.4 升级到 2.6 的类
- python - 如何使用 python 截断 db 结果以进行断言?
- git - 在 gitignore 中引用多个在线 gitignore 模板
- node.js - 我的 env 文件似乎无法正常工作。
- google-colaboratory - 直接 Google Colab 链接
- javascript - 我们可以在``之后使用嵌套表吗?