【发布时间】:2021-06-17 17:06:20
【问题描述】:
我有一个应用程序,我希望在 Active MQ Artemis 中有 1 个持久队列和 1 个非持久队列。 为了连接到这个消息总线,我使用 amqpnetlite。
var source = new Source()
{
};
if (durable)
{
source.Address = amqpAddressConverter.GetSubscriberAddress(address, useLoadBalancing);
source.Durable = 1;
source.ExpiryPolicy = new Symbol("never");
source.DistributionMode = new Symbol("copy");
}
else
{
source.Address = amqpAddressConverter.GetSubscriberAddress(address);
source.Durable = 0;
source.ExpiryPolicy = "never";
}
var receiverLink = new ReceiverLink(session, linkName, source, null);
所以这是我的接收器链接。如图所示,我设置了 Source 的 Durable uint,它将提供给 ReceiverLink。
因为正如我在 Active MQ Artemis 文档中看到的那样,Durable 是一个布尔值,但在 amqpnetlite 库中,我的理解是超过 0 的所有内容都应该为真,而 0 应该为假。
一开始这种行为很奇怪:即使在 Aretemis Web 界面显示为持久队列时,只要没有连接消费者,它就会被删除。
我发现了这个: ActiveMQ Artemis queue deleted after shutdown of consuming client 它描述了由于默认行为,即使是持久队列也会被删除。
所以我操作了 broker.xml 并将 AUTO-DELETE-QUEUE 设置为 false。
从那时起,行为完全转变: 连接断开后,(durable = 1 和durable = 0)队列仍然存在。
那么如何正确创建持久连接和非持久连接呢?
【问题讨论】:
标签: c# amqp activemq-artemis