为什么是Rebus.使用Azure服务总线发送更新到.net 5后不工作



我们有一个。net core 3.1 web项目,使用Rebus和Azure Service Bus运行。

在更新到。net 5之后,我们不能再使用Rebus向Azure服务总线队列发送消息。没有做任何代码更改,只是更新到。net 5和最新的rebus包(6.6.1)。

var contractMessage = _manager.GetContractMessage();
await _bus.Send(contractMessage);

这一扔:

Exception
Rebus.Exceptions.RebusApplicationException: Could not send to queue 'sbq-queue-queue1'
---> System.InvalidOperationException: Operation is not valid due to the current state of the object.
at Microsoft.Azure.ServiceBus.Core.MessageSender.OnSendAsync(IList`1 messageList)
at Microsoft.Azure.ServiceBus.RetryPolicy.RunOperation(Func`1 operation, TimeSpan operationTimeout)
at Microsoft.Azure.ServiceBus.RetryPolicy.RunOperation(Func`1 operation, TimeSpan operationTimeout)
at Microsoft.Azure.ServiceBus.Core.MessageSender.SendAsync(IList`1 messageList)
at Rebus.AzureServiceBus.AzureServiceBusTransport.<>c__DisplayClass36_0.<<GetOutgoingMessages>g__SendOutgoingMessagesToDestination|3>d.MoveNext()
--- End of inner exception stack trace ---
at Rebus.AzureServiceBus.AzureServiceBusTransport.<>c__DisplayClass36_0.<<GetOutgoingMessages>g__SendOutgoingMessagesToDestination|3>d.MoveNext()
--- End of stack trace from previous location ---
at Rebus.AzureServiceBus.AzureServiceBusTransport.<>c__DisplayClass36_1.<<GetOutgoingMessages>g__SendOutgoingMessages|1>d.MoveNext()
--- End of stack trace from previous location ---
at Rebus.Transport.TransactionContext.InvokeAsync(Func`2 actions)
at Rebus.Transport.TransactionContext.Complete()
at Rebus.Bus.RebusBus.InnerSend(IEnumerable`1 destinationAddresses, Message logicalMessage)
at Rebus.Bus.RebusBus.Send(Object commandMessage, IDictionary`2 optionalHeaders)
at xx.xx.xx.xx.xx.someclass.request.mediatrHandler.Handle(ClassRequest request, CancellationToken cancellationToken) in /home/vsts/work/1/s/xx.xx.xx/Application/xx/xx/xxRequest.cs:line 187

奇怪的是,这似乎在本地调试时有效,但在生产服务器上不起作用,生产服务器是运行IIS的azure虚拟机。

要连接到ASB,我已经尝试了管理身份和完整连接字符串。

使用包:

Rebus 6.6.1
Rebus.AzureServiceBus 9.0.5
Rebus.Serilog 6.0.0
Rebus.Serviceprovider 6.4.1

和在ConfigureServices中设置Rebus:

services.AddRebus((options, serviceProvider) => options
.Logging(l => l.Serilog())
.Transport(t => t.UseAzureServiceBusAsOneWayClient(configuration["RebusConfig:AzureServiceBusConnectionString"]))
.Routing(r => {
r.TypeBased().MapAssemblyOf<Contract1>(configuration["RebusConfig:Routes:Route1"])
.MapAssemblyOf<Contract2>(configuration["RebusConfig:Routes:Route2"]);
})
);

将Microsoft Azure软件包更新到最新版本并将所有Azure服务的连接切换到新的DefaultAzureCredentials()后,此问题自行解决。

相关内容

  • 没有找到相关文章

最新更新