Tim_
Tim_
CC#
Created by Tim_ on 1/14/2024 in #help
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.
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;
}
}
Output when publishing an event
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
1 replies
CC#
Created by Tim_ on 9/16/2022 in #help
Nuget private source
I'm trying to add use a few private nuget sources with Microsoft identity authentication. I can get it working in Rider (opens a popup to sign in) but I am unable to get this to work in visual studio. There seems to be hardly any info about this
2 replies