amqp 的 nodejs rhea npm 无法在 activemq artemis 中的地址上创建订阅队列

nodejs rhea npm for amqp couldn't create subscription queue on address in activemq artemis

我有一个地址 "pubsub.foo" 已经在 broker.xml 中配置为多播。

<address name="pubsub.foo">
   <multicast/>
</address>

根据 Artemis documentation:

When clients connect to an address with the multicast element, a subscription queue for the client will be automatically created for the client.

我正在使用 rhea AMQP Node.js npm 创建一个简单的实用程序来将消息发布到地址。

var connection = require('rhea').connect({ port: args.port, host: args.host, username:'admin', password:'xxxx' });

var sender = connection.open_sender('pubsub.foo');
sender.on('sendable', function(context) {
    var m = 'Hii test' 
    console.log('sent ' + m);
    sender.send({body:m});
    connection.close();
});

我启用了调试日志,当 运行 客户端代码时,我看到了这样的消息。

2020-02-03 22:43:25,071 DEBUG [org.apache.activemq.artemis.core.postoffice.impl.PostOfficeImpl] Message org.apache.activemq.artemis.protocol.amqp.broker.AMQPMessage@68933e4b is not going anywhere as it didn't have a binding on address:pubsub.foo

我也尝试了该主题的不同变体,例如,client1.pubsub.foopubsub.foo::client1,但客户端代码没有成功。请分享您的想法。我是 ActiveMQ Artemis 的新手。

您实际观察到的是预期的行为。

很遗憾,您引用的文档不够清晰。当它说将创建订阅队列以响应客户端连接时,它实际上意味着 订阅者 而不是生产者。这就是它创建 subscription 队列的原因。多播地址的语义(通常是 publish/subscribe)规定当没有订阅者时发送的消息将被丢弃。因此,您需要创建订阅者,然后然后发送消息。

如果您想要不同的语义,那么我建议您使用任播。