Masstransit 通过 MachineName_iisexpress 生成 AWS SQS 队列。

huangapple go评论71阅读模式
英文:

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 =&gt;
{
    busRegistrationConfiguration.AddConsumer&lt;GenericConsumer&gt;();

    busRegistrationConfiguration.UsingAmazonSqs((context, cfg) =&gt;
    {
        string awsRegion = Configuration.GetValue&lt;string&gt;(&quot;AWS-Region&quot;);
      
        cfg.Host(awsRegion, host =&gt;
        {
            host.AccessKey(Configuration.GetValue&lt;string&gt;(&quot;AWS-AccessID&quot;));
            host.SecretKey(Configuration.GetValue&lt;string&gt;(&quot;AWS-Secret&quot;));
        });
        cfg.AutoStart = true;
        cfg.ReceiveEndpoint(&quot;nxt-sqs-dev&quot;, x =&gt;
        {
            x.UseMessageRetry(r =&gt; r.Interval(2, TimeSpan.FromMilliseconds(5000)));

            x.ConfigureConsumeTopology = false;
            x.Subscribe(&quot;fe-nxt-sqs-dev&quot;);

            x.Consumer&lt;GenericConsumer&gt;(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&lt;GenericConsumer&gt;(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&lt;GenericConsumer&gt;(context)

huangapple
  • 本文由 发表于 2023年2月14日 06:11:52
  • 转载请务必保留本文链接:https://go.coder-hub.com/75441687.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定