Search code examples
.net-coreamazon-sqsmasstransit

MassTransit & Amazon SQS - EventType being created as a queue


I have just migrated from RabbitMq to Amazon SQS.

One thing that's happening which I dont want is the Message Type is being created as queue when I use docker & IHostedService startup:

public void ConfigureServices(IServiceCollection services)
    {
        services.AddMassTransit(x =>
        {
            x.AddConsumer<EmailSentConsumer>();

            x.AddBus(provider => Bus.Factory.CreateUsingAmazonSqs(cfg =>
            {
                cfg.Host("eu-west-2", h =>
                {
                    h.AccessKey("********");
                    h.SecretKey("********");
                });

                cfg.ReceiveEndpoint("logging_example_queue", e =>
                {
                    //e.ConfigureConsumer<EmailSentConsumer>(provider);
                    //e.ConfigureConsumer<EmailReceivedConsumer>(provider);
                });

                cfg.ConfigureEndpoints(provider);
            }));
        });

        services.AddSingleton<IHostedService, BusService>();

        services.AddMassTransitHostedService();
    }

public class EmailSentConsumer : IConsumer<EmailSent>

EmailSent is being set up as a queue, when I just want this service listening for that event type in the logging_example_queue.

When I set this up via a simple console app, and have the Consumers within the configure endpoint

            cfg.ReceiveEndpoint("logging_queue", e =>
            {
                e.Consumer<ConsumerTo>();
                e.Consumer<AnotherConsumer>();
            });

This works fine, any suggestions?

EDIT

So, I have tried Chris answer, and this doesn't create the queue as suggested, but I do need the topic. I want this as an example:

Topic EmailSent: Queue: Logging Queue: EmailListener

Here are the screenshots from AWS:

enter image description here

enter image description here


Solution

  •             cfg.ReceiveEndpoint("logging_example_queue", e =>
                {
                    //e.ConfigureConsumer<EmailSentConsumer>(provider);
                    //e.ConfigureConsumer<EmailReceivedConsumer>(provider);
                });
    
                cfg.ConfigureEndpoints(provider);
    

    This is the issue, fixed this by changing the configureendpoints, as below:

                    cfg.ReceiveEndpoint("logging_example_queue", e =>
                    {
                        e.ConfigureConsumers(provider);
                    });