MassTransit: Consumers not getting called
I'm having trouble setting up masstransit. For some reason my consumers aren't getting called. The published events are saved to the database but they're not getting sent to rabbitmq for some reason.
Output when publishing an event
services.AddMassTransit(opt =>
{
opt.SetKebabCaseEndpointNameFormatter();
opt.AddConsumer<UserRegisteredEventHandler>();
opt.AddEntityFrameworkOutbox<TContext>(o =>
{
o.QueryDelay = TimeSpan.FromSeconds(1);
o.UsePostgres();
o.UseBusOutbox();
});
opt.UsingRabbitMq((context, o) =>
{
o.Host("localhost", "/", h =>
{
h.Username("user123");
h.Password("pass123");
});
o.ConfigureEndpoints(context);
});
});
services.AddMassTransit(opt =>
{
opt.SetKebabCaseEndpointNameFormatter();
opt.AddConsumer<UserRegisteredEventHandler>();
opt.AddEntityFrameworkOutbox<TContext>(o =>
{
o.QueryDelay = TimeSpan.FromSeconds(1);
o.UsePostgres();
o.UseBusOutbox();
});
opt.UsingRabbitMq((context, o) =>
{
o.Host("localhost", "/", h =>
{
h.Username("user123");
h.Password("pass123");
});
o.ConfigureEndpoints(context);
});
});
public class UserRegisteredEventHandler : IConsumer<UserRegisteredEvent>
{
private readonly ILogger<UserRegisteredEvent> _logger;
public UserRegisteredEventHandler(ILogger<UserRegisteredEvent> logger)
{
_logger = logger;
}
public Task Consume(ConsumeContext<UserRegisteredEvent> context)
{
_logger.LogInformation(context.Message.ToString());
return Task.CompletedTask;
}
}
public class UserRegisteredEventHandler : IConsumer<UserRegisteredEvent>
{
private readonly ILogger<UserRegisteredEvent> _logger;
public UserRegisteredEventHandler(ILogger<UserRegisteredEvent> logger)
{
_logger = logger;
}
public Task Consume(ConsumeContext<UserRegisteredEvent> context)
{
_logger.LogInformation(context.Message.ToString());
return Task.CompletedTask;
}
}
17:32 [Information] (Users) MassTransit
Configured endpoint "user-registered-event-handler", Consumer: "Shared.Infrastructure.Messaging.UserRegisteredEventHandler"
17:32 [Information] (Users) Users.Application.Commands.RegisterUser.Handler
At RegisterUser
17:32 [Information] (Users) MassTransit
Configured endpoint "user-registered-event-handler", Consumer: "Shared.Infrastructure.Messaging.UserRegisteredEventHandler"
17:32 [Information] (Users) Users.Application.Commands.RegisterUser.Handler
At RegisterUser
0 Replies