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

标签 jms hornetq activemq-artemis

我的任务是评估 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/

相关文章:

java - 在Hornetq中配置发往 "Expired message address"的消息的过期时间

java - 用于异步调用的 Apache Camel

Hornetq - 将 1 个队列连接到多个地址?

java - 使用核心 api 消费后 HornetQ 消息仍保留在队列中

apache-camel - 用于从 ActiveMQ Artemis 传输消息或向 ActiveMQ Artemis 传输消息的 SJMS2 与 JMS 组件

java - 在 Websphere 8.5 上使用 JMS 时出现 NoSuchMethodError 错误

java - WildFly 11 ActiveMQ Web 控制台

jms - HornetQ 2.2.5 嵌入示例异常

java - Artemis-2.6.3 控制台 : Service Unavailable

wildfly - Wildfly 10 集群(域)中的 Artemis (ActiveMQ) 消息传递