我正在尝试将消息发送到队列。队列已存在,并配置为非持久性。这是我的代码:
ServiceBus = Bus.Factory.CreateUsingRabbitMq(sbc =>
{
sbc.PurgeOnStartup = true;
sbc.Durable = false;
sbc.Exclusive = false;
sbc.Host(new Uri($"rabbitmq://{RabbitMqHost}"), cfg =>
{
cfg.ConfigureRabbitMq();
});
});
ServiceBus.Request(
new Uri(serviceUri),
new EngineStartingMessage() { Version = ApplicationConfig.SystemVersion },
rCfg =>
{
rCfg.Durable = false;
rCfg.Timeout = new TimeSpan(0, 0, 30);
rCfg.Handle<EngineStartingResponse>(async hContext =>
{
//Response handling
});
});
如您所见,Durable设置为false。在ServiceBus.Request上,我得到以下异常:
AMQP操作被中断:AMQP关闭原因,由Peer发起,代码= 406,text =“PRECONDITION_FAILED - 不等效arg'持久'用于交换'QUEUENAMEHERE'在vhost'/'中:收到'true'但当前是'false' “,classId = 40,methodId = 10,cause =
任何想法为什么消息仍然发送持久?
该Durable标志仅指定不应将特定请求消息持久保存到磁盘。
如果要解决此问题,请将?durable=false
添加到serviceUri,以匹配处理请求的接收端点处指定的内容。