public static class RabbitMQRegistrar
{
public static void ConfigureRabbitMQ(this IServiceCollection services, IConfiguration configuration)
{
var rabbitMqOptions = configuration.GetSection("RabbitMQ:Settings").Get<RabbitMqOptions>();
var authServiceRabbitMqEndPointsOptions = configuration.GetSection("RabbitMQ:EndPoints:AuthService").Get<AuthServiceRabbitMqEndpointsOptions>();
var authServiceRabbitMqEndPoints = authServiceRabbitMqEndPointsOptions;
services.AddMassTransit(busConfigurator => busConfigurator.AddBus(provider => Bus.Factory.CreateUsingRabbitMq(cfg =>
{
cfg.Host(rabbitMqOptions.HostName, hostConfig =>
{
hostConfig.Username(rabbitMqOptions.UserName);
hostConfig.Password(rabbitMqOptions.Password);
});
cfg.ReceiveEndpoint(authServiceRabbitMqEndPoints.UserCreatedEventQueue, ep => ep.Consumer<AuthServiceUserCreatedMessageConsumer>(provider));
})));
services.ConfigureRabbitMQBaseOptions(configuration);
}
}
public static class RabbitMQRegistrar
{
public static void ConfigureRabbitMQ(this IServiceCollection services, IConfiguration configuration)
{
var rabbitMqOptions = configuration.GetSection("RabbitMQ:Settings").Get<RabbitMqOptions>();
var authServiceRabbitMqEndPointsOptions = configuration.GetSection("RabbitMQ:EndPoints:AuthService").Get<AuthServiceRabbitMqEndpointsOptions>();
var authServiceRabbitMqEndPoints = authServiceRabbitMqEndPointsOptions;
services.AddMassTransit(busConfigurator => busConfigurator.AddBus(provider => Bus.Factory.CreateUsingRabbitMq(cfg =>
{
cfg.Host(rabbitMqOptions.HostName, hostConfig =>
{
hostConfig.Username(rabbitMqOptions.UserName);
hostConfig.Password(rabbitMqOptions.Password);
});
cfg.ReceiveEndpoint(authServiceRabbitMqEndPoints.UserCreatedEventQueue, ep => ep.Consumer<AuthServiceUserCreatedMessageConsumer>(provider));
})));
services.ConfigureRabbitMQBaseOptions(configuration);
}
}