MassTransit fails to connect to existing AWS SNS/SQS

Currently, I’m attempting to move from aws sdk to MassTransit. And I have a big issue with connecting to the SQS/SNS.
Our infrastructure team created sqs/sns using a terraform script. And we (as developers and application) cannot change (in any way) it since the infrastructure is managed by a separate team and another aws account/role.

We’re using MassTransit 8.0 (the newest version)

Basically we have:
queue:

name: bci-name-dev-aim-name

encryption: SSE-SQS

Where we have SNS subscription:

arn:aws:sqs:us-west-2::bci-name-dev-aim-name to topic: bci-name-dev-aim-name-topic (protocol SQS)

As a topic

name: bci-name-dev-aim-name-topic

encryption: default one (alias/aws/sns)

My producer configuration looks:

services.AddMassTransit(cfg =>
                {
                    cfg.UsingAmazonSqs((context, bus) =>
                    {
                        bus.UseMessageScheduler(schedulerEndpoint);
            
                        bus.Host("us-west-2", h => {}); //using env Variables

                        bus.Message<PublicationMessage>(x =>
                        {
                            x.SetEntityName("bci-name-dev-aim-name-topic");
                        });
                        
                        bus.ConfigureEndpoints(context);
                    });
                });

My consument:

services.AddMassTransit(cfg =>
                {
                    cfg.AddConsumer<PublicationMessageConsumer>();
        
                    cfg.UsingAmazonSqs((context, bus) =>
                    {                            
                        bus.Host("us-west-2", h => {});

                        
                        bus.PublishTopology.TopicAttributes.Add(QueueAttributeName.KmsMasterKeyId, "alias/aws/sns");

                        bus.ReceiveEndpoint("bci-name-dev-aim-name", ec =>  //queue name
                        {
                            // disable the default topic binding
                            ec.ConfigureConsumeTopology = false;
                            ec.QueueAttributes.Add(QueueAttributeName.KmsMasterKeyId, "alias/aws/sqs");
                            
                            ec.Subscribe("bci-name-dev-aim-name-topic");    //topic name
                            
                            ec.ConfigureConsumer<PublicationMessageConsumer>(context);
                        });
                        
                        bus.ConfigureEndpoints(context);
                    });
                });

After starting the application (console app). Producer is reports (during starting app):

  info: MassTransit[0]
  Bus started: amazonsqs://us-west-2/

But when I tried to start consumer I got:

  info: MassTransit[0]
  Configured endpoint bci-name-dev-aim-name, Consumer: Consumer.PublicationMessageConsumer

(thats’s the only log so no bus started log etc)

When I stop the consumer I receive:

  warn: MassTransit[0]
  Failed to stop bus: amazonsqs://us-west-2/BKOWALCZYKW1_Consumer_bus_kotoyynbyybfbeanbdpf9sykno?durable=false&autodelete=true (Not Started)

Can you advise?

++++++ EDITED:

I tried to adapt to suggestions from @Chris Patterson. And currently my configuration looks:

Producer:

services.AddMassTransit(cfg =>
                {
                    cfg.UsingAmazonSqs((context, bus) =>
                    {
                        bus.UseMessageScheduler(schedulerEndpoint);
            
                        bus.Host("us-west-2", h => {}); //using env Variables

                        bus.Message<PublicationMessage>(x =>
                        {
                            x.SetEntityName("bci-name-dev-aim-name-topic");
                        });
                        
                        bus.ConfigureEndpoints(context);
                    });
                });

Consumer:

services.AddMassTransit(cfg =>
                {
                    cfg.AddConsumer<PublicationMessageConsumer>();
        
                    cfg.UsingAmazonSqs((context, bus) =>
                    {                            
                        bus.Host("us-west-2", h => {});

                        bus.ReceiveEndpoint("bci-name-dev-aim-name", ec =>  //queue name
                        {
                            // disable the default topic binding
                            ec.ConfigureConsumeTopology = false;
                         
                            ec.ConfigureConsumer<PublicationMessageConsumer>(context);
                        });
                        
                        bus.ConfigureEndpoints(context);
                    });
                });

And It looks like the consumer reported: “Bus started: amazonsqs://us-west-2/”.
So it works

2

If the SQS queue is already created, the SNS topic already created, and the subscription from SNS->SQS is already created, you should remove the .Subscribe call since it will try to create the subscription in the topic.

Also, setting queue/topic attributes in MassTransit won’t do anything since the topic and queue have already been created.

That should configure MassTransit to work with the least number of permissions. You’ll also want to likely pre-create the _error queue in the event of an error, or configure MassTransit to use the standard SQS dead-letter queue and redrive policy.

2

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật