/// <summary> /// 使用RabbitMq做事件总线 /// </summary> /// <param name="options"></param> /// <param name="configure"></param> /// <returns></returns> public static EventBusOptions UseRabbitMQ(this EventBusOptions options, Action <EventBusRabbitMqOptions> configure) { if (configure == null) { throw new ArgumentNullException(nameof(configure)); } var setting = new EventBusRabbitMqOptions(); configure.Invoke(setting); options.RegisterExtension(new EventBusRabbitMqOptionsExtension(setting)); return(options); }
public EventBusRabbitMQ(IRabbitMQPersistentConnection persistentConnection, ILogger <EventBusRabbitMQ> logger, IServiceProvider autofac, IEventBusSubscriptionsManager subsManager, IOptions <EventBusRabbitMqOptions> options) { _persistentConnection = persistentConnection ?? throw new ArgumentNullException(nameof(persistentConnection)); _logger = logger ?? throw new ArgumentNullException(nameof(logger)); _subsManager = subsManager ?? throw new ArgumentNullException(nameof(subsManager)); _options = options.Value; _queueName = _options.QueueName; _autofac = autofac; _prefetchCount = _options.PrefetchCount; _retryCount = _options.RetryCount; _subsManager.OnEventRemoved += SubsManager_OnEventRemoved; }
public DefaultRabbitMQPersistentConnection(IOptions <EventBusRabbitMqOptions> options, ILogger <DefaultRabbitMQPersistentConnection> logger) { _options = options.Value; _connectionFactory = new ConnectionFactory { HostName = _options.HostName, Port = _options.Port, UserName = _options.UserName, Password = _options.Password, VirtualHost = _options.VirtualHost }; _logger = logger ?? throw new ArgumentNullException(nameof(logger)); _retryCount = _options.RetryCount; }
/// <summary> /// 使用RabbitMq做事件总线 /// </summary> /// <param name="options"></param> /// <param name="configure"></param> /// <returns></returns> public static EventBusOptions UseRabbitMQ(this EventBusOptions options, IConfiguration configuration) { if (configuration == null) { throw new ArgumentNullException(nameof(configuration)); } var setting = new EventBusRabbitMqOptions(); configuration.GetSection("EventBus").GetSection("RabbitMQ").Bind(setting); options.RegisterExtension(new EventBusRabbitMqOptionsExtension(setting)); return(options); }
public EventBusRabbitMqOptionsExtension(EventBusRabbitMqOptions options) { _options = options; }