0

I have two consumers each in separated micro service

namespace MyCoreApp.Consumers;
public class CustomerCreatedConsumer : IConsumer<DomainEvents.CustomerCreatedEvent>
{
    private readonly IPublishEndpoint _publisher;

    public CustomerCreatedConsumer(IPublishEndpoint publisher)
    {
        _publisher = publisher;
    }

    public async Task Consume(ConsumeContext<DomainEvents.CustomerCreatedEvent> context)
    {
        await _publisher.Publish(new IntegrationEvents.CustomerCreatedEvent
        {                
            CustomerId = context.Message.CustomerId                
        });
    }
}

There are two subscribers to this IntegrationEvents.CustomerCreatedEvent message. As soon as first service picks up the message the other service it ends and other service doesn't get message to consume.

Is this the right way to emit an event to multiple subscribers on MassTransit?

 await _publisher.Publish(new IntegrationEvents.CustomerCreatedEvent
 {                
     CustomerId = context.Message.CustomerId                
 });
user1765862
  • 13,635
  • 28
  • 115
  • 220

0 Answers0