public RabbitMQPublisher( ILogger <RabbitMQPublisher> _logger , RabbitMQOptions rabbitMqOptions , PersistentConnection connection) { this._logger = _logger; _rabbitMqOptions = rabbitMqOptions; _connection = connection; }
public RabbitMQSubscriber( ILogger <RabbitMQSubscriber> logger , RabbitMQOptions rabbitMqOptions , PersistentConnection connection) { _logger = logger; _rabbitMqOptions = rabbitMqOptions; _connection = connection; }
public static SmartSqlDIBuilder AddRabbitMQPublisher(this SmartSqlDIBuilder smartSqlDiBuilder, Action <RabbitMQOptions> configure) { RabbitMQOptions rabbitMqOptions = new RabbitMQOptions(); configure?.Invoke(rabbitMqOptions); smartSqlDiBuilder.Services.AddSingleton(rabbitMqOptions); smartSqlDiBuilder.Services.TryAddSingleton <PersistentConnection>(); smartSqlDiBuilder.Services.TryAddSingleton <IPublisher, RabbitMQPublisher>(); smartSqlDiBuilder.Services.TryAddSingleton <ISubscriber, RabbitMQSubscriber>(); return(smartSqlDiBuilder); }
public PersistentConnection(RabbitMQOptions rabbitMqOptions , ILogger <PersistentConnection> logger) { _connectionFactory = new ConnectionFactory { HostName = rabbitMqOptions.HostName, UserName = rabbitMqOptions.UserName, Password = rabbitMqOptions.Password, VirtualHost = rabbitMqOptions.VirtualHost, RequestedHeartbeat = rabbitMqOptions.RequestedHeartbeat, AutomaticRecoveryEnabled = rabbitMqOptions.AutomaticRecoveryEnabled }; _logger = logger ?? throw new ArgumentNullException(nameof(logger)); }
public static SmartSqlDIBuilder AddRabbitMQPublisher(this SmartSqlDIBuilder smartSqlDiBuilder, Action <RabbitMQOptions> configure) { RabbitMQOptions rabbitMqOptions = new RabbitMQOptions(); configure?.Invoke(rabbitMqOptions); smartSqlDiBuilder.Services.AddSingleton <IPublisher, RabbitMQPublisher>(sp => { var loggerFactory = sp.GetRequiredService <ILoggerFactory>(); return(new RabbitMQPublisher(loggerFactory.CreateLogger <RabbitMQPublisher>() , rabbitMqOptions , new PersistentConnection(rabbitMqOptions, loggerFactory.CreateLogger <PersistentConnection>() ))); }); return(smartSqlDiBuilder); }