AMQPNETLITE-ActiveMQ Artemis(Red Hat AMQ)-自动创建多消费者多播队列 [英] AMQPNETLITE - ActiveMQ Artemis (Red Hat AMQ) - autocreate multi-consumer multicast queue
问题描述
此问题是关于使用.Net中的AMQP消耗消息的.该文档建议使用amqpnetlite: https://access.redhat.com/documentation/zh-CN/red_hat_amq/7.0/html-single/using_the_amq_.net_client/index
This qeuestion is on consuming the messages using AMQP in .Net. The documentation recommends amqpnetlite: https://access.redhat.com/documentation/en-us/red_hat_amq/7.0/html-single/using_the_amq_.net_client/index
使用AMQPNetLite订阅地址时,将自动创建地址和队列.但是,自动创建的队列始终是单播"的.我无法自动创建
On subscribing to an address using AMQPNetLite, the address and the queue will be auto-created. The auto-created queue is always "unicast" though. I have not been able to auto-create
- 多播队列
- 允许任何数量的消费者.
代码:
private async Task RenewSession()
{
Connect = await Connection.Factory.CreateAsync(new Address("amqp://admin:admin@localhost:5672"), new Open() {ContainerId = "client-1"});
MqSession = new Session(Connect);
var receiver = new ReceiverLink(MqSession, DEFAULT_SUBSCRIPTION_NAME, GetSource("test-topic"), null);
receiver.Start(100, OnMessage);
}
private Source GetSource(string address)
{
var source = new Source
{
Address = address,
ExpiryPolicy = new Symbol("never"),
Durable = 2,
DefaultOutcome = new Modified
{
DeliveryFailed = true,
UndeliverableHere = false
}
};
return source;
}
也许我缺少一些标志?
推荐答案
在AMQP中,您可以通过设置功能来自动创建队列(任意播路由)或主题(多播路由).
in AMQP, you choose between autocreating a queue (anycast routing) or a topic (multicast routing) by setting a capability.
该功能应为new Symbol("queue")
或new Symbol("topic")
.
public class SimpleAmqpTest
{
[Fact]
public async Task TestHelloWorld()
{
Address address = new Address("amqp://guest:guest@localhost:5672");
Connection connection = await Connection.Factory.CreateAsync(address);
Session session = new Session(connection);
Message message = new Message("Hello AMQP");
Target target = new Target
{
Address = "q1",
Capabilities = new Symbol[] { new Symbol("queue") }
};
SenderLink sender = new SenderLink(session, "sender-link", target, null);
await sender.SendAsync(message);
Source source = new Source
{
Address = "q1",
Capabilities = new Symbol[] { new Symbol("queue") }
};
ReceiverLink receiver = new ReceiverLink(session, "receiver-link", source, null);
message = await receiver.ReceiveAsync();
receiver.Accept(message);
await sender.CloseAsync();
await receiver.CloseAsync();
await session.CloseAsync();
await connection.CloseAsync();
}
}
看看> https://github.com/Azure/amqpnetlite/issues/286 ,代码来自哪里.
您可以通过在broker.xml中设置default-address-routing-type
来选择默认路由是多播还是任意播,所有内容记录在
You can choose whether the default routing will be multicast or anycast by setting default-address-routing-type
in broker.xml, everything documented at https://activemq.apache.org/artemis/docs/2.6.0/address-model.html
未为AMQP实现代理的multicastPrefix
和anycastPrefix
功能. https://issues.jboss.org/browse/ENTMQBR-795
The broker's multicastPrefix
and anycastPrefix
feature is not implemented for AMQP. https://issues.jboss.org/browse/ENTMQBR-795
这篇关于AMQPNETLITE-ActiveMQ Artemis(Red Hat AMQ)-自动创建多消费者多播队列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!