private static IBusControl CreateUsingRabbitmq(AmqpOptions options) { return(Bus.Factory.CreateUsingRabbitMq(x => { x.Host(new Uri($"{options.Host}"), configurator => { configurator.Username(options.UserName); configurator.Password(options.Password); }); })); }
public RabbitMqBrokerConfigurationBuilder(IConfiguration configuration, IServiceCollection serviceCollection) { _serviceCollection = serviceCollection; _options = new AmqpOptions(); configuration.GetSection(nameof(AmqpOptions)).Bind(_options); _busControl = _options.InMemory ? CreateUsingInMemory() : CreateUsingRabbitmq(_options); _messageBroker = new MessageBroker(_busControl); serviceCollection.AddSingleton(typeof(IMessageBroker), _ => _messageBroker); serviceCollection.AddHostedService <MessageBrokerHostedService>(); serviceCollection.AddSingleton(_busControl); }