英文:
Masstransit generating is AWS SQS queues with MachineName_iisexpress
问题
我在使用 Mass Transit 时遇到了配置问题。它在 AWS SQS 上生成带有 MachineName_iisexpress... 的队列。
我在启动时有以下配置:
services.AddMassTransit(busRegistrationConfiguration =>
{
busRegistrationConfiguration.AddConsumer<GenericConsumer>();
busRegistrationConfiguration.UsingAmazonSqs((context, cfg) =>
{
string awsRegion = Configuration.GetValue<string>("AWS-Region");
cfg.Host(awsRegion, host =>
{
host.AccessKey(Configuration.GetValue<string>("AWS-AccessID"));
host.SecretKey(Configuration.GetValue<string>("AWS-Secret"));
});
cfg.AutoStart = true;
cfg.ReceiveEndpoint("nxt-sqs-dev", x =>
{
x.UseMessageRetry(r => r.Interval(2, TimeSpan.FromMilliseconds(5000)));
x.ConfigureConsumeTopology = false;
x.Subscribe("fe-nxt-sqs-dev");
x.Consumer<GenericConsumer>(context);
});
//cfg.ConfigureEndpoints(context);
});
});
我尝试更改配置,但无法解决我的问题,也查阅了文档等。
英文:
I am having a configuration problem with mass transit. It generates queues with MachineName_iisexpress... on AWS SQS.
I have the following config on startup:
services.AddMassTransit(busRegistrationConfiguration =>
{
busRegistrationConfiguration.AddConsumer<GenericConsumer>();
busRegistrationConfiguration.UsingAmazonSqs((context, cfg) =>
{
string awsRegion = Configuration.GetValue<string>("AWS-Region");
cfg.Host(awsRegion, host =>
{
host.AccessKey(Configuration.GetValue<string>("AWS-AccessID"));
host.SecretKey(Configuration.GetValue<string>("AWS-Secret"));
});
cfg.AutoStart = true;
cfg.ReceiveEndpoint("nxt-sqs-dev", x =>
{
x.UseMessageRetry(r => r.Interval(2, TimeSpan.FromMilliseconds(5000)));
x.ConfigureConsumeTopology = false;
x.Subscribe("fe-nxt-sqs-dev");
x.Consumer<GenericConsumer>(context);
});
//cfg.ConfigureEndpoints(context);
});
});
I did try to change the configuration but I couldn't solve my issue, did check the documentation etc.
答案1
得分: 0
不要设置 cfg.AutoStart = true;
,除非你希望 MassTransit 启动总线端点(使用唯一的临时队列名称,在你的情况下是 MachineName_iisexpress_etc...)。总线端点仅在你使用该总线实例的请求客户端时才会使用。删除该语句,MassTransit 将不会创建总线端点或其队列,除非你确实使用了该总线实例的请求客户端。
另外,与此无关,但你应该使用以下方式配置你的消费者:
x.ConfigureConsumer<GenericConsumer>(context)
英文:
Do not set cfg.AutoStart = true;
unless you want MassTransit to start the bus endpoint (which uses a unique temporary queue name, in your case, MachineName_iisexpress_etc...). The bus endpoint is only used when you are using the request client from that bus instance. Remove that statement and MassTransit won't create the bus endpoint or its queue unless you actually use the request client from that bus instance.
Also, unrelated, but you should be configuring your consumer using:
x.ConfigureConsumer<GenericConsumer>(context)
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论