0
votes

I am working on a .net core 3.1 app, for some reason my messages are not getting consumed.

service configuration :

services.AddMassTransit(x =>
        {
            x.AddConsumer<ItemAddedConsumer>();
            x.AddBus(provider => Bus.Factory.CreateUsingRabbitMq(cfg =>
            {
                cfg.UseHealthCheck(provider);
                cfg.Host(new Uri($"rabbitmq://{rMqSettings.host}:{rMqSettings.port}"), h =>
                               {
                                   h.Username(rMqSettings.username);
                                   h.Password(rMqSettings.password);
                               });
                cfg.ReceiveEndpoint("items-service.ItemAdded", ep =>
                {
                    ep.ConfigureConsumeTopology=false;
                    ep.Bind("ItemAdded");
                    ep.PrefetchCount = 15;
                    ep.Consumer<ItemAddedConsumer>(provider);
                });

consumer class :

public class ItemAddedConsumer : IConsumer<ItemAdded>
{
    private readonly IMediator _mediator;

    public ItemAddedConsumer(IMediator mediator)
    {
        _mediator = mediator;
    }

    public async Task Consume(ConsumeContext<ItemAdded> context)
    {
        await _mediator.Send(new ItemAdded(context.Message.Id));
    }
}

and this is how i am sending the messages :

            Uri uri = new Uri("exchange:ItemAdded?bind=true&queue=items-service.ItemAdded");
            var endPoint = await _bus.GetSendEndpoint(uri);
            await endPoint.Send(@event);

all messages get sent to a new queue called items-service.ItemAdded_skipped queues

1

1 Answers

0
votes

Make sure the sent message and the consumer are using the same message type, including namespace, as outlined in the docs.

Also, why the overly complicated send endpoint address and receive endpoint configuration? You can change the EntityName of the message (via attribute or the publish topology) and simply use Publish from your message producer.