简体   繁体   中英

MassTransit with SQS/SNS. Messages not publishing to SQS queues

I am trying to subscribe a SNS topic to SQS queue using the masstransit configuration mentioned in their docs. The messages are published but do not appear in the SQS queues. SQS queue name: "test", SNS Topic name: "kbbico-manual-to-replace".

public void ConfigureServices(IServiceCollection services)
        {
            services.AddControllers();

            services.AddMassTransit(x =>
            {
                /*Configuring a receive endpoint will use the message topology to create and subscribe SNS topics to SQS queues so that 
                 * published messages will be delivered to the receive endpoint queue*/
                x.AddConsumer<OfferConsumer>();
                x.UsingAmazonSqs((context, cfg) =>
                {
                    cfg.Host("ca-central-1", h =>
                    {
                        //h.Config(AmazonSQSConfig);
                        //h.Config(AmazonSnsConfig);                     
                    });

                    cfg.ReceiveEndpoint("test", e =>
                    {
                        e.ConfigureConsumer<OfferConsumer>(context);
                        // disable the default topic binding
                        //e.ConfigureConsumeTopology = false;

                        //Topic subscibed to a recieve endpoint
                        e.Subscribe("kbbico-manual-to-replace", s =>
                        {
                            // set topic attributes
                            s.TopicAttributes["DisplayName"] = "Public Event Topic";
                            s.TopicSubscriptionAttributes["some-subscription-attribute"] = "some-attribute-value";
                            s.TopicTags.Add("environment", "development");
                        });
                    });
                    cfg.ConfigureEndpoints(context);
                });


            });
            services.AddMassTransitHostedService();
        }

You didn't configure a consumer, so the messages are likely being moved to the _skipped queue (or maybe the SQS DLQ).

Also, the cfg.ConfigureEndpoints() within the host configuration does not belong there at all. It should come at the very end of the bus configuration.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM