java - Spring 入站 channel 适配器的最大数量是多少?

标签 java spring jms spring-integration

我有一个 Spring 集成配置文件,例如:

<int-jms:inbound-channel-adapter
        channel="fromjmsRecon"
        jms-template="jmsTemplate"
        destination-name="com.mycompany.inbound.recon">
    <int:poller fixed-delay="3000" max-messages-per-poll="1"/>
</int-jms:inbound-channel-adapter>
<int:publish-subscribe-channel id="fromjmsRecon"/>
<int:service-activator input-channel="fromjmsRecon"
                       ref="processInboundReconFile"
                       method="execute"/>

... 10 More inbound channels ...

<int-jms:inbound-channel-adapter
        channel="fromjmsVanRecon"
        jms-template="jmsTemplate"
        destination-name="com.mycompany.inbound.another">
    <int:poller fixed-delay="3000" max-messages-per-poll="1"/>
</int-jms:inbound-channel-adapter>
<int:publish-subscribe-channel id="fromjmsVanRecon"/>
<int:service-activator input-channel="fromjmsVanRecon"
                       ref="processInboundAnother"
                       method="execute"/>

</beans>

有 11 个入站 channel 适配器。前 10 个连接到 ActiveMQ,但第 11 个从未连接。这些适配器的列出顺序无关紧要,第 11 个适配器始终会被忽略。服务适配器已初始化,但 channel 适配器从未连接到 ActiveMQ。

入站 channel 适配器的数量有限制吗?我可以在某处设置一个属性来更改此限制吗?

感谢您的帮助。

最佳答案

正确,有一个名为 TaskScheduler 的限制线程池大小10 :

http://docs.spring.io/spring-integration/reference/html/configuration.html#namespace-taskscheduler

因此,考虑使用 spring.integration.taskScheduler.poolSize 更改其大小使用属性(property)TaskExecutor对于那些适配器将任务转移到其他线程并且不吃昂贵的TaskScheduler .

还有其他方法:不要使用<int-jms:inbound-channel-adapter> ,但切换到 <int-jms:message-driven-channel-adapter> ,这是本质上的倾听,而且效果更好。

关于java - Spring 入站 channel 适配器的最大数量是多少?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38516234/

相关文章:

spring - ResultHandler.print() 未定义

JavaFX 在 fxml 中调整 Canvas 大小

java.swing.Timer 不停止

java - 在单元测试中调用 Spring Repository.save() 时未触发 Hibernate Validator

spring - Thymeleaf 模型属性是否不允许以 'is' 开头?

java - 如何优雅地关闭 Spring JMS MessageListenerAdapter

java - 消息传递(例如 JMS)何时可以替代多线程?

java - 使用 Thymeleaf 在脚本标签中发送安全参数

java - JAVA如何知道哪个列表被选中

jakarta-ee - 向 JBoss 集群域中的所有节点发送消息