【问题标题】:Performance settings for ActiveMQ producer using Apache Camel in Spring boot framework在 Spring Boot 框架中使用 Apache Camel 的 ActiveMQ 生产者的性能设置
【发布时间】: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


【解决方案1】:
  1. 是的,您需要使用 pooledConnectionFactory。尤其是骆驼+弹簧靴。或者看看使用 camel-sjms 组件。罪魁祸首是 Spring 的 JMSTemplate。超高延迟。

  2. 发送 NON_PERSISTENT 和 AUTO_ACK,同时在连接工厂上开启 sendAsync

  3. 您需要在路由中捕获 javax.jms.ResourceAllocationException 以在生产者流控制启动时重试(又名队列或代理已满)

  4. ActiveMQ 根据字节而不是消息计数来确定大小。请参阅 Producer Flow Control 文档和 Per-Destination Policies 策略中的 SystemUsage 设置,以根据字节限制队列大小。

【讨论】:

    猜你喜欢
    • 2023-03-13
    • 1970-01-01
    • 2018-01-31
    • 1970-01-01
    • 2011-01-08
    • 2023-03-31
    • 1970-01-01
    • 1970-01-01
    • 2020-03-10
    相关资源
    最近更新 更多