【发布时间】:2021-04-22 05:15:29
【问题描述】:
我们有一个 spring boot 应用程序,我们使用 apache camel 作为消息处理框架。我们正在尝试最好地优化我们的应用程序设置,以使 ActiveMQ 队列上的消息排队速度更快,队列另一端的 Logstash 作为消费者接收这些消息。
文档分散在很多地方,可用的配置太多。
例如,camel link for spring boot 指定了 102 个选项。同样,activemq apache camel link 详细说明了这些内容。
这是我们当前配置的:
Application.properties:
################################################
# Spring Active MQ
################################################
spring.activemq.broker-url=tcp://localhost:61616
spring.activemq.packages.trust-all=true
spring.activemq.user=admin
spring.activemq.password=admin
阿帕奇骆驼
.to("activemq:queue:"dataQueue"?messageConverter=#queueMessageConverter");
问题:
1 - 我们怀疑我们必须使用 poolConnectionFactory 而不是默认的 Spring JMS 模板 bean,它以某种方式自动获取。
2 - 我们还希望该过程是异步的。我们只想将消息放在队列中,不想等待来自 activemq 的任何 ACK 或执行任何重试或其他操作。
3 - 我们希望仅在队列已满时等待重试。
4 - 我们应该在哪里设置 ActiveMq 大小的设置?如果没有可用的消费者,activemq 还会将东西放入死信队列吗?我们希望覆盖该行为并希望将消息保留在那里。 (这是否必须在 Activemq 中配置,而不是在我们的 app/apache camel 中)
更新 这是我们经过更多调查并基于目前的反馈解决了这个问题。注意:这不涉及重试,因为我们将尝试答案中建议的选项。
对于 Seda 队列:
制作人:
.to("seda:somequeue?waitForTaskToComplete=Never");
消费者:
.from("seda:somequeue?concurrentConsumers=20");
活动 MQ:
.to("activemq:queue:dataQueue?disableReplyTo=true);
Application.Properties:
#Enable poolconnection factory
spring.activemq.pool.enabled=true
spring.activemq.pool.blockIfFull=true
spring.activemq.pool.max-connections=50
【问题讨论】:
-
你在这里问的问题太多了。每个问题都应该集中在一个问题上。另外,您是否考虑过使用ActiveMQ Artemis? ActiveMQ Artemis 的整体性能比 ActiveMQ 5.x 好很多,尤其是随着客户端数量的增加。
标签: java spring spring-boot apache-camel activemq