gpt4 book ai didi

c# - MassTransit 3,其中 AzureServiceBus 在队列名称前添加斜杠

转载 作者:行者123 更新时间:2023-12-03 01:52:25 24 4
gpt4 key购买 nike

当我尝试使用 MassTransit 3 在 Azure 中运行应用程序时,出现以下错误

The entity name or path cannot contain '/' as prefix or suffix. The supplied value is '/profile.api'. Parameter name: entityName

我可以看到添加到队列名称的前缀的唯一方法是通过 MassTransit。

奇怪的是,队列已在我的 Azure 门户中以“profile.api”名称创建。

以前有其他人经历过这种情况吗?我不确定这是否是 MassTransit 的错误,或者我是否错过了配置中的某个步骤。

完整的堆栈跟踪如下。

谢谢。

[ArgumentException: The entity name or path cannot contain '/' as prefix or suffix. The supplied value is '/profile.api'. Parameter name: entityName]
Microsoft.ServiceBus.Common.AsyncResult.End(IAsyncResult result) +381 Microsoft.ServiceBus.Messaging.MessagingFactory.EndCreateMessageReceiver(IAsyncResult result) +70
System.Threading.Tasks.TaskFactory1.FromAsyncCoreLogic(IAsyncResult
iar, Func
2 endFunction, Action1 endAction, Task1 promise, Boolean requiresSynchronization) +86
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) +99
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +58
MassTransit.AzureServiceBusTransport.Pipeline.-Send>d__7.MoveNext() +794 System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() +26 MassTransit.AzureServiceBusTransport.Pipeline.-Send>d__7.MoveNext() +2756 System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) +99
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +58
MassTransit.AzureServiceBusTransport.Pipeline.d__5.MoveNext() +1599 System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) +99
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +58
MassTransit.AzureServiceBusTransport.<b__0>d.MoveNext() +531 System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) +99
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +58
MassTransit.Internals.Extensions.d__01.MoveNext()
+924 System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task
task) +99<br/>
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
task) +58 MassTransit.<StartAsync>d__29.MoveNext() +1154<br/>
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() +26<br/>
MassTransit.<StartAsync>d__29.MoveNext() +2025<br/>
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task
task) +99<br/>
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
task) +58 MassTransit.Util.TaskUtil.Await(Func
1 taskFactory, CancellationToken cancellationToken) +222
MassTransit.MassTransitBus.MassTransit.IBusControl.Start() +61
SampleApp.Startup.ConfigureBus() +33
SampleApp.Startup.Configuration(IAppBuilder app) +428

最佳答案

事实证明,与 MassTransit 测试运行其 azure 配置的方式相比,我的应用程序的配置方式存在非常微妙的差异。

而我有(不起作用)

public class AzureBusModule : Autofac.Module
{
protected override void Load(ContainerBuilder builder)
{
builder.Register(context =>
{
var busControl = Bus.Factory.CreateUsingAzureServiceBus(sbc =>
{
var host = sbc.Host(new Uri("sb://" + ConfigurationManager.AppSettings["AzureEndPoint"]), h =>
{
h.OperationTimeout = TimeSpan.FromSeconds(5);
h.TokenProvider = TokenProvider.CreateSharedAccessSignatureTokenProvider(
ConfigurationManager.AppSettings["AzureKeyName"],
ConfigurationManager.AppSettings["AzureKeyValue"]);
});

sbc.UseSerilog();
sbc.UseJsonSerializer();
//sbc.UseRetry(Retry.Exponential(10.Seconds(), 3.Minutes(), 10.Seconds()));

sbc.ReceiveEndpoint(host, ConfigurationManager.AppSettings["QueueName"], ep =>
{
ep.LoadFrom(context);
});

});

Log.Information("Finished Configuring MassTransit using Azure");

return busControl;
})
.SingleInstance()
.As<IBusControl>()
.As<IBus>();
}
}

更改以下内容解决了我的问题。

var serviceUri = ServiceBusEnvironment.CreateServiceUri("sb",
ConfigurationManager.AppSettings["AzureEndpoint"],
ConfigurationManager.AppSettings["AzureEndpointName"]);

var host = sbc.Host(serviceUri, h =>
{
// [...]
}

我希望这对遇到类似问题的其他人有所帮助。

关于c# - MassTransit 3,其中 AzureServiceBus 在队列名称前添加斜杠,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33723112/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com