gpt4 book ai didi

jms - 如何解决新安装的 ActiveMQ Artemis 上的阻塞问题?

转载 作者:行者123 更新时间:2023-12-01 18:30:21 26 4
gpt4 key购买 nike

我的任务是评估 JMS 客户端的 ActiveMQ Artemis。我有 RabbmitMQ 经验,但没有 ActiveMQ Artemis 和 JMS 经验。

我将 Artemis 安装到本地计算机,按照说明创建了一个新代理,并将其设置为 Windows 服务。 Windows 服务启动和停止都很好。我没有对 broker.xml 文件进行任何更改。

对于我的第一个测试,我尝试从独立的 Java 程序执行 JMS 队列生产/消费。我正在使用《Artemis 用户手册》中“使用 JMS”部分的代码(不使用 JNDI):

TransportConfiguration transportConfiguration = new TransportConfiguration(NettyConnectorFactory.class.getName());
ConnectionFactory cf = ActiveMQJMSClient.createConnectionFactoryWithoutHA(JMSFactoryType.CF,transportConfiguration);

Queue orderQueue = ActiveMQJMSClient.createQueue("OrderQueue");
Connection connection = cf.createConnection();
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);

MessageProducer producer = session.createProducer(orderQueue);
MessageConsumer consumer = session.createConsumer(orderQueue);

connection.start();

TextMessage message = session.createTextMessage("This is an order");
producer.send(message);

TextMessage receivedMessage = (TextMessage)consumer.receive();
System.out.println("Got order: " + receivedMessage.getText());

当我运行此代码时,出现以下错误:

WARN: AMQ212054: Destination address=jms.queue.OrderQueue is blocked. If the system is configured to block make sure you consume messages on this configuration.

我的研究还没有确定这是服务器端设置还是让生产者在不阻塞的情况下发送。我一直无法找到具有阻塞 bool 值的生产者发送方法,只有持久性。关于重点在哪里有什么想法吗?谢谢。

编辑:新的address-setting元素添加到专用于此队列的broker.xml中:

<address-setting match="jms.queue.OrderQueue">
<max-size-bytes>104857600</max-size-bytes>
<page-size-bytes>10485760</page-size-bytes>
<address-full-policy>PAGE</address-full-policy>
</address-setting>

最佳答案

我在用户手册中进一步研究时发现了这一点:

max-disk-usage The max percentage of data we should use from disks.The System will block while the disk is full. Default=100

服务启动后的日志中尚未发布任何消息:

WARN [org.apache.activemq.artemis.core.server] AMQ222210: Storage usage is beyond max-disk-usage. System will start blocking producers.

所以我认为无论我的地址设置如何,它都会开始阻塞。查看broker.xml 中的 max-disk-usage 设置,它被设置为 90。文档默认值为 100,我设置为该值,没有启动日志警告,并且我的测试发布/订阅代码现在可以工作。

关于jms - 如何解决新安装的 ActiveMQ Artemis 上的阻塞问题?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44726181/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com