public Biz( ILoggerFactory loggerFactory, IConnectionFactory connectionFactory, IExchangeComDeclareParameters exchangeDeclareParameters, IQueueComDeclareParameters queueDeclareParameters, INotifierMediatorService notifierMediatorService, ITagGroupReady tagGroupReady, IAllTagGroupAllConnection allTagGroupAllConnection, IComponentContext componentContext ) { _loggerFactory = loggerFactory; _logger = _loggerFactory.CreateLogger <Biz>(); _connectionFactory = connectionFactory; _exchangeDeclareParameters = exchangeDeclareParameters; _queueDeclareParameters = queueDeclareParameters; _notifierMediatorService = notifierMediatorService; _tagGroupReady = tagGroupReady; _allTagGroupAllConnection = allTagGroupAllConnection; _componentContext = componentContext; _machineName = Environment.MachineName; _logger.LogInformation("KBase.Business.Com startup machine name: " + _machineName); PersistentConnection = new DefaultRabbitMqPersistentConnection(_connectionFactory, _loggerFactory); }
public void SetUp() { _subscriptionManager = Substitute.For <ISubscriptionManager>(); _rabbitMqPersistentConnection = Substitute.For <IRabbitMqPersistentConnection>(); _rabbitConsumerInitializer = Substitute.For <IRabbitConsumerInitializer>(); var rabbitMqEventBusOptions = Substitute.For <IOptions <RabbitMqEventBusOptions> >(); var value = Substitute.For <RabbitMqEventBusOptions>(); rabbitMqEventBusOptions.Value.Returns(value); _rabbitMqEventBusOptionsValue = value; var queueName = Guid.NewGuid().ToString(); var exchangeName = Guid.NewGuid().ToString(); value.QueueName.Returns(queueName); value.ExchangeName.Returns(exchangeName); _model = Substitute.For <IModel>(); _rabbitMqPersistentConnection.CreateModel().Returns(_model); _subscription = new Subscription <Event>(); _subscriptionManager.AddSubscription <Event>().Returns(_subscription); _sut = new RabbitMqEventSubscriber(_subscriptionManager, _rabbitMqPersistentConnection, _rabbitConsumerInitializer, rabbitMqEventBusOptions, Substitute.For <ILogger <RabbitMqEventSubscriber> >()); _rabbitConsumerInitializer.Received(1).InitializeConsumersChannelsAsync(); }
public EventBusRabbitMQ( IServiceProvider serviceProvider, ILogger <EventBusRabbitMQ> logger, string directExchangeName = "", string fanoutExchangeName = "", string directQueueName = "", int retryCount = 5) { _serviceProvider = serviceProvider ?? throw new ArgumentNullException(nameof(serviceProvider)); _logger = logger ?? NullLogger <EventBusRabbitMQ> .Instance; _persistentConnection = serviceProvider.GetService <IRabbitMqPersistentConnection>() ?? throw new ArgumentNullException(nameof(_persistentConnection)); _subsManager = serviceProvider.GetService <IEventBusSubscriptionsManager>() ?? new InMemoryEventBusSubscriptionsManager(); if (directExchangeName == fanoutExchangeName) { throw new InvalidOperationException("direct exchange mast different from fanout exchange"); } _directExchangeName = directExchangeName; _fanoutExchangeName = fanoutExchangeName; _directQueueName = directQueueName; _retryCount = retryCount; // 创建直连模式消费者信道 _consumerChannel = CreateConsumerChannel(); // 创建广播模式消费者信道 _listenChannel = CreateListingChannel(); _subsManager.OnEventRemoved += SubsManager_OnEventRemoved; }
//protected readonly IEventBusRpcServer _eventBusRpcServer; public Test() { Configuration.ProtoBufConfiguration(); LoggerFactory = Microsoft.Extensions.Logging.LoggerFactory.Create(builder => { builder.AddConsole(); builder.SetMinimumLevel(LogLevel.Trace); }); ConnectionFactory = new ConnectionFactory { HostName = "localhost", UserName = "******", Password = "******", AutomaticRecoveryEnabled = true, NetworkRecoveryInterval = TimeSpan.FromSeconds(10), RequestedHeartbeat = TimeSpan.FromSeconds(10), DispatchConsumersAsync = true }; ExchangeDeclareParameters = new ExchangeDeclareParameters("k-society_test", KSociety.Base.EventBus.ExchangeType.Direct, false, ExchangeAutoDelete); QueueDeclareParameters = new QueueDeclareParameters(false, false, QueueAutoDelete); PersistentConnection = new DefaultRabbitMqPersistentConnection(ConnectionFactory, LoggerFactory); var builder = new ContainerBuilder(); builder.RegisterModule(new Bindings.Test.Test()); var container = builder.Build(); ComponentContext = container.BeginLifetimeScope(); }
public RabbitMqEventBus(string queueName) { _subsManager = new InMemorySubscriptionsManager(); _persistentConnection = new DefaultRabbitMqPersistentConnection(); _queueName = queueName ?? ""; _consumerChannel = CreateConsumerChannel(); _subsManager.OnEventRemoved += SubsManager_OnEventRemoved; }
public RabbitMqEventBus(IRabbitMqPersistentConnection persistentConnection, ILogger <RabbitMqEventBus> logger, IServiceProvider serviceProvider) { _persistentConnection = persistentConnection; _logger = logger; _serviceProvider = serviceProvider; _retryCount = 5; _subscriptions = new Dictionary <Type, RabbitMqSubscription>(); }
public EventBusRabbitMq( IRabbitMqPersistentConnection persistentConnection, IServiceProvider serviceProvider) { _persistentConnection = persistentConnection; _serviceProvider = serviceProvider; _consumer = CreateConsumerChannel(); }
public DefaultRabbitMqMessageConsumer( IRabbitMqPersistentConnection connection, ILogger <DefaultRabbitMqMessageConsumer> logger) { _logger = logger; _persistentConnection = connection; ProcessEvents = new ConcurrentBag <Func <IModel, BasicDeliverEventArgs, Task> >(); BindingQueueRoutingKeys = new ConcurrentDictionary <string, string>(); }
public RabbitEventPublisher( IOptions <RabbitMqEventBusOptions> options, IRabbitMqPersistentConnection persistentConnection, ILogger <RabbitEventPublisher> logger) { _persistentConnection = persistentConnection; _logger = logger; _options = options.Value; }
public EventBusRabbitMqQueue(IRabbitMqPersistentConnection persistentConnection, ILoggerFactory loggerFactory, IIntegrationGeneralHandler eventHandler, IEventBusSubscriptionsManager subsManager, IExchangeDeclareParameters exchangeDeclareParameters, IQueueDeclareParameters queueDeclareParameters, string queueName = null, CancellationToken cancel = default) : base(persistentConnection, loggerFactory, eventHandler, subsManager, exchangeDeclareParameters, queueDeclareParameters, queueName, cancel) { ConsumerChannel = CreateConsumerChannel(cancel); }
public RabbitConsumerInitializer( IRabbitMqPersistentConnection persistentConnection, IOptions <RabbitMqEventBusOptions> options, IRabbitConsumerHandler rabbitConsumerHandler, ILogger <RabbitConsumerInitializer> logger) { _persistentConnection = persistentConnection; _rabbitConsumerHandler = rabbitConsumerHandler; _logger = logger; _rabbitMqEventBusOptions = options.Value; EnsureQueueAndExchangeAreCreated(); }
public RabbitMqEventBus(IRabbitMqPersistentConnection persistentConnection, ILogger <RabbitMqEventBus> logger, IEventBusSubscriptionsManager subsManager, string queueName = null, int retryCount = 5) { _persistentConnection = persistentConnection ?? throw new ArgumentNullException(nameof(persistentConnection)); _logger = logger ?? throw new ArgumentNullException(nameof(logger)); _subsManager = subsManager ?? new InMemoryEventBusSubscriptionsManager(); _queueName = queueName; _consumerChannel = CreateConsumerChannel(); _retryCount = retryCount; _subsManager.OnEventRemoved += SubsManager_OnEventRemoved; }
private void Initialize() { _persistentConnection = new DefaultRabbitMqPersistentConnection(_connectionFactory, _loggerFactory); _eventBus = new EventBusRabbitMqTyped( _persistentConnection, _loggerFactory, null, _exchangeDeclareParameters, _queueDeclareParameters, "LogQueueDriver", CancellationToken.None); }
public RabbitMqMessagePublisher( IServiceScopeFactory serviceScopeFactory, IRabbitMqPersistentConnection persistentConnection, IOptions <EventBusRabbitMqOptions> options, ILogger <RabbitMqMessagePublisher> logger) : base(serviceScopeFactory) { _persistentConnection = persistentConnection; _options = options; _logger = logger; }
public NotificationPublisher(IRabbitMqPersistentConnection persistentConnection, IEventBusSubscriptionsManager subsManager, IServiceProvider serviceProvider, int retryCount = 5) { _persistentConnection = persistentConnection; _subsManager = subsManager; _retryCount = retryCount; _serviceProvider = serviceProvider; _consumerChannel = CreateConsumerChannel(); }
public EventBusRabbitMq(IServiceProvider sp, IRabbitMqPersistentConnection persistentConnection, ILogger <EventBusRabbitMq> logger, IEventBusSubscriptionsManager subsManager, string queueName, int retryCount) { this.sp = sp; this.persistentConnection = persistentConnection ?? throw new ArgumentNullException(nameof(persistentConnection)); this.logger = logger ?? throw new ArgumentNullException(nameof(logger)); this.subsManager = subsManager ?? new InMemoryEventBusSubscriptionsManager(); this.queueName = queueName; consumerChannel = CreateConsumerChannel(); this.retryCount = retryCount; this.subsManager.OnEventRemoved += SubsManager_OnEventRemoved; }
public RabbitMqEventSubscriber( ISubscriptionManager subscriptionManager, IRabbitMqPersistentConnection persistentConnection, IRabbitConsumerInitializer rabbitConsumerInitializer, IOptions <RabbitMqEventBusOptions> rabbitMqEventBusOptons, ILogger <RabbitMqEventSubscriber> logger) { _subscriptionManager = subscriptionManager; _persistentConnection = persistentConnection; _rabbitConsumerInitializer = rabbitConsumerInitializer; _logger = logger; _rabbitMqEventBusOptions = rabbitMqEventBusOptons.Value; }
// ReSharper disable once SuggestBaseTypeForParameter public EventBusRabbitMq(IServiceProvider serviceProvider, ILogger <EventBusRabbitMq> logger, IOptions <BusSetting> options, IRabbitMqPersistentConnection persistentConnection, IEventBusSubscriptionsManager subscriptionsManager) { _serviceProvider = serviceProvider; _logger = logger; _options = options.Value; _persistentConnection = persistentConnection ?? throw new ArgumentNullException(nameof(persistentConnection)); _subscriptionsManager = subscriptionsManager ?? _serviceProvider.GetRequiredService <InMemoryEventBusSubscriptionsManager>(); //_consumerChannel = CreateConsumerChannel(); _subscriptionsManager.OnEventRemoved += SubsManager_OnEventRemoved; }
public EventBusRabbitMq(IRabbitMqPersistentConnection persistentConnection, ILifetimeScope autoFac, IEventBusSubscriptionsManager subsManager, string queueName = null, int retryCount = 5) { _persistentConnection = persistentConnection ?? throw new ArgumentNullException(nameof(persistentConnection)); _subsManager = subsManager ?? new InMemoryEventBusSubscriptionsManager(); _queueName = queueName; _consumerChannel = CreateConsumerChannel(); _autoFac = autoFac; _retryCount = retryCount; }
public RabbitMQEventBusClient( IRabbitMqPersistentConnection rabbitMqPersistentConnection, ILogger logger, string queueName, int retryCount) { _directExchangeRabbitMQManager = new DirectExchangeRabbitMqManager(); _rabbitMqPersistentConnection = rabbitMqPersistentConnection; _logger = logger; _queueName = queueName; _retryCount = retryCount == default ? DefaultRetryCount : retryCount; _consumerChannel = CreateConsumerChannel(); }
public EventBusRabbitMqRpcServer(IRabbitMqPersistentConnection persistentConnection, ILoggerFactory loggerFactory, IIntegrationGeneralHandler eventHandler, IEventBusSubscriptionsManager subsManager, IExchangeDeclareParameters exchangeDeclareParameters, IQueueDeclareParameters queueDeclareParameters, string queueName = null, CancellationToken cancel = default) : base(persistentConnection, loggerFactory, eventHandler, subsManager, exchangeDeclareParameters, queueDeclareParameters, queueName, cancel) { SubsManager.OnEventReplyRemoved += SubsManager_OnEventReplyRemoved; ConsumerChannel = CreateConsumerChannel(cancel); _queueNameReply = QueueName + "_Reply"; _consumerChannelReply = CreateConsumerChannelReply(cancel); }
public EventBusRabbitMq(IRabbitMqPersistentConnection persistentConnection, ILogger <EventBusRabbitMq> logger, ILifetimeScope autofac, IEventBusSubscriptionsManager subsManager, string exchangeType = ExchangeTypes.Direct, string queueName = null, int retryCount = 5) { this.persistentConnection = persistentConnection ?? throw new ArgumentNullException(nameof(persistentConnection));; this.logger = logger ?? throw new ArgumentNullException(nameof(logger));; this.subsManager = subsManager ?? new InMemoryEventBusSubscriptionsManager();; this.autofac = autofac; this.exchangeType = exchangeType; this.queueName = queueName; this.retryCount = retryCount; this.consumerChannel = this.CreateConsumerChannel(); this.subsManager.OnEventRemoved += this.SubsManager_OnEventRemoved; }
public EventBusRabbitMq(IRabbitMqPersistentConnection persistentConnection, ILogger <EventBusRabbitMq> logger, ILifetimeScope container, IEventBusSubscriptionsManager subsManager, string queueName = null, int retryCount = 5) { this._persistentConnection = persistentConnection ?? throw new ArgumentNullException(paramName: nameof(persistentConnection)); this._logger = logger ?? throw new ArgumentNullException(paramName: nameof(logger)); this._subsManager = subsManager ?? new InMemoryEventBusSubscriptionsManager(); this._queueName = queueName; this._consumerChannel = this.CreateConsumerChannel(); this._container = container; this._retryCount = retryCount; this._subsManager.OnEventRemoved += this.SubsManager_OnEventRemoved; }
protected EventBusRabbitMq(IRabbitMqPersistentConnection persistentConnection, ILoggerFactory loggerFactory, IEventBusSubscriptionsManager subsManager, IExchangeDeclareParameters exchangeDeclareParameters, IQueueDeclareParameters queueDeclareParameters, string queueName = null, CancellationToken cancel = default) { ExchangeDeclareParameters = exchangeDeclareParameters; PersistentConnection = persistentConnection ?? throw new ArgumentNullException(nameof(persistentConnection)); Logger = loggerFactory.CreateLogger <EventBusRabbitMq>() ?? throw new ArgumentNullException(nameof(loggerFactory)); SubsManager = subsManager ?? new InMemoryEventBusSubscriptionsManager(); QueueDeclareParameters = queueDeclareParameters; QueueName = queueName; EventHandler = null; SubsManager.OnEventRemoved += SubsManager_OnEventRemoved; }
/// <summary> /// Constrsuctor /// </summary> /// <param name="persistentConnection"></param> /// <param name="logger"></param> /// <param name="autofac"></param> /// <param name="subscriptionManager"></param> /// <param name="option"></param> public EventBusRabbitMq(IRabbitMqPersistentConnection persistentConnection, ILogger <EventBusRabbitMq> logger, ILifetimeScope autofac, IEventBusSubscriptionsManager subscriptionManager, RabbitMqOption option) { _queueName = option.Client ?? throw new ArgumentNullException(nameof(option.Client)); _brokerName = option.Exchange ?? throw new ArgumentNullException(nameof(option.Exchange)); _autofacScopeName = option.Scope ?? $"scope_{option.Exchange}_{option.Client}"; _persistentConnection = persistentConnection ?? throw new ArgumentNullException(nameof(persistentConnection)); _logger = logger ?? throw new ArgumentNullException(nameof(logger)); _subscriptionsManager = subscriptionManager ?? new InMemoryEventBusSubscriptionsManager(); _autofac = autofac; _subscriptionsManager.OnEventRemoved += SubscriptionManager_OnEventRemoved; _consumerChannel = CreateConsumerChannel(); _retryCount = option.PublishRetryCount; }
public Biz( ILoggerFactory loggerFactory, IConnectionFactory connectionFactory, IExchangeDeclareParameters exchangeDeclareParameters, IQueueDeclareParameters queueDeclareParameters) { _loggerFactory = loggerFactory; _logger = _loggerFactory.CreateLogger <Biz>(); _connectionFactory = connectionFactory; _exchangeDeclareParameters = exchangeDeclareParameters; _queueDeclareParameters = queueDeclareParameters; _logger.LogInformation("C20052.Biz.Log biz! "); PersistentConnection = new DefaultRabbitMqPersistentConnection(_connectionFactory, _loggerFactory); }
public EventBusRabbitMq(IRabbitMqPersistentConnection persistentConnection, ILogger <EventBusRabbitMq> logger, IEventBusSubscriptionsManager subsManager, ILifetimeScope autofac, string queueName, int retryCount) { _persistentConnection = persistentConnection ?? throw new ArgumentNullException(nameof(persistentConnection)); _logger = logger ?? throw new ArgumentNullException(nameof(logger)); _subsManager = subsManager ?? throw new ArgumentNullException(nameof(subsManager)); _autofac = autofac ?? throw new ArgumentNullException(nameof(autofac)); _queueName = queueName; _retryCount = retryCount; _consumerChannel = CreateConsumerChannel(); }
public RabbitMqEventBus ( IServiceProvider serviceProvider, IEventBusSubscriptionManager subscriptionManager, IRabbitMqPersistentConnection persistentConnection, string queueName, int retryCount = 5 ) { _queueName = queueName; _retryCount = retryCount; _serviceProvider = serviceProvider; _subscriptionManager = subscriptionManager; _persistentConnection = persistentConnection; _subscriptionManager.OnEventRemoved += SubscriptionManager_OnEventRemoved; }
public RabbitMqPersistentConnectionTests() { var services = new ServiceCollection(); services.AddLinFx() .AddRabbitMqPersistentConnection(options => { options.Host = "127.0.0.1"; options.UserName = "******"; options.Password = "******"; }); var sp = services.BuildServiceProvider(); _persistentConnection = sp.GetRequiredService <IRabbitMqPersistentConnection>(); }
public EventBusRabbitMQ(IRabbitMqPersistentConnection persistentConnection, ILifetimeScope autofac, IEventBusSubscriptionsManager subsManager, ILogger logger, bool isServer, Action <IEventBus> action = null) { _isServer = isServer; _persistentConnection = persistentConnection ?? throw new ArgumentNullException(nameof(persistentConnection)); _subsManager = subsManager ?? new InMemoryEventBusSubscriptionsManager(); _autofac = autofac; _queueName = QueueName; _subsManager.OnEventRemoved += SubsManager_OnEventRemoved; _logger = logger; if (!isServer) { action?.Invoke(this); _consumerChannel = CreateConsumerChannel(); } }