我想知道我是否做错了什么,我希望MassTransit会自动ReceiveEndpoints在EndpointConvention.
示例代码:
services.AddMassTransit(x =>
{
x.AddServiceBusMessageScheduler();
x.AddConsumersFromNamespaceContaining<MyNamespace.MyRequestConsumer>();
x.UsingAzureServiceBus((context, cfg) =>
{
// Load the connection string from the configuration.
cfg.Host(context.GetRequiredService<IConfiguration>().GetValue<string>("ServiceBus:ConnectionString"));
cfg.UseServiceBusMessageScheduler();
// Without this line I'm getting an error complaining about no endpoint convention for x could be found.
EndpointConvention.Map<MyRequest>(new Uri("queue:queue-name"));
cfg.ReceiveEndpoint("queue-name", e =>
{
e.MaxConcurrentCalls = 1;
e.ConfigureConsumer<MyRequestConsumer>(context);
});
cfg.ConfigureEndpoints(context);
});
});
Run Code Online (Sandbox Code Playgroud)
我认为EndpointConvention.Map<MyRequest>(new Uri("queue:queue-name"));在不指定队列名称的情况下允许发送到总线不需要这条线,或者我错过了什么?
await bus.Send<MyRequest>(new { ...});
masstransit ×1