You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在ActiveMQ Artemis服务器端修改或禁用minLargeMessageSize?

问题描述

使用ActiveMQ Artemis 2.19搭配带ActiveMQJMSConnectionFactory的Camel JMS客户端,发送10MB文件时希望不被标记为大消息,但设置minLargeMessageSize参数完全无效——所有发送的消息都会被打上大消息标签。已经试过以下几种方法,均未解决问题:

  • 在acceptor上配置minLargeMessageSize属性
  • 在客户端JMS连接上设置minLargeMessageSize属性
  • 调用factory.setMinLargeMessageSize(1000000)代码设置
  • 替换成ActiveMQConnectionFactory而非ActiveMQJMSConnectionFactory

另外,只有bytes类型消息会出现这个问题,测试用的路由配置如下:

<bean id="artemisConnectionFactory" class="org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory">
    <argument index="0" value="tcp://IP:61616"/>
    <argument index="1" value="login"/>
    <argument index="2" value="pass"/>
    <property name="minLargeMessageSize" value="99999999"/>
</bean>

<bean id="jms" class="org.apache.camel.component.jms.JmsComponent">
    <property name="connectionFactory" ref="artemisConnectionFactory"/>
</bean>

<camelContext id="test-broker" xmlns="http://camel.apache.org/schema/blueprint">
    <route>
        <from uri="file:///home/dev/files"/>
        <to uri="jms:test_queue"/>
    </route>

    <route>
    <from uri="jetty:http://0.0.0.0:8182/testbroker"/>
        <pollEnrich timeout="10">
            <simple>jms:test_queue</simple>
        </pollEnrich>
    </route>
</camelContext>
解决方案

1. 开启Camel JMS组件的延迟生产者创建

Camel JMS默认会缓存消息生产者,这可能导致连接工厂的minLargeMessageSize配置无法生效。给JMS组件添加lazyCreateMessageProducer="true",让每次发送消息都创建新的生产者,确保读取最新的连接工厂配置:

<bean id="jms" class="org.apache.camel.component.jms.JmsComponent">
    <property name="connectionFactory" ref="artemisConnectionFactory"/>
    <property name="lazyCreateMessageProducer" value="true"/>
</bean>

2. 禁用Camel自身的消息大小检查

Camel在处理大文件时会自动判断并标记为大消息,这会绕过Artemis的配置。直接在JMS端点URI添加disableMessageSizeCheck="true",同时显式指定消息类型为Bytes:

<to uri="jms:test_queue?jmsMessageType=Bytes&amp;disableMessageSizeCheck=true"/>

3. 确认Broker端的acceptor配置

检查Broker的broker.xml,确保对应acceptor的minLargeMessageSize配置正确,单位是字节(比如设置为100MB即104857600,确保10MB消息+消息头不会超过阈值):

<acceptors>
    <acceptor name="tcp-acceptor">tcp://IP:61616?minLargeMessageSize=104857600</acceptor>
</acceptors>

4. 核实消息的实际总大小

注意Artemis的minLargeMessageSize判断的是消息整体大小,包括消息头、属性和消息体。如果10MB文件加上消息头后超过了你设置的阈值,也会被标记为大消息,可以适当调大minLargeMessageSize的值(比如设为11000000)。

内容的提问来源于stack exchange,提问作者Thaideval

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.16 04:34:56