Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
579 views
in Technique[技术] by (71.8m points)

asp.net core 3.1 - MassTransit rabbitMq - Why are all my messages skipped

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

question from:https://stackoverflow.com/questions/65887692/masstransit-rabbitmq-why-are-all-my-messages-skipped

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...