コード例 #1
0
ファイル: ConnectionChannelPool.cs プロジェクト: zmk523/CAP
        public ConnectionChannelPool(ILogger <ConnectionChannelPool> logger,
                                     RabbitMQOptions options)
        {
            _logger  = logger;
            _maxSize = DefaultPoolSize;

            _connectionActivator = CreateConnection(options);
        }
コード例 #2
0
        public RabbitMQConsumerClient(string queueName, RabbitMQOptions options)
        {
            _queueName       = queueName;
            _rabbitMQOptions = options;
            _exchageName     = options.TopicExchangeName;

            InitClient();
        }
コード例 #3
0
 public PublishQueueExecutor(ILogger <PublishQueueExecutor> logger, CapOptions options,
                             RabbitMQOptions rabbitMQOptions, IConnectionChannelPool connectionChannelPool, IStateChanger stateChanger)
     : base(options, stateChanger, logger)
 {
     _logger = logger;
     _connectionChannelPool = connectionChannelPool;
     _rabbitMQOptions       = rabbitMQOptions;
 }
コード例 #4
0
ファイル: PublishQueueExecutor.cs プロジェクト: skywshing/CAP
 public PublishQueueExecutor(IStateChanger stateChanger,
                             IOptions <RabbitMQOptions> options,
                             ILogger <PublishQueueExecutor> logger)
     : base(stateChanger, logger)
 {
     _logger          = logger;
     _rabbitMQOptions = options.Value;
 }
コード例 #5
0
 public RabbitMQConsumerClient(string queueName,
                               IConnectionChannelPool connectionChannelPool,
                               IOptions <RabbitMQOptions> options)
 {
     _queueName             = queueName;
     _connectionChannelPool = connectionChannelPool;
     _rabbitMQOptions       = options.Value;
     _exchangeName          = connectionChannelPool.Exchange;
 }
コード例 #6
0
 public RabbitMQPublishMessageSender(ILogger <RabbitMQPublishMessageSender> logger, CapOptions options,
                                     IStorageConnection connection, IConnectionChannelPool connectionChannelPool, IStateChanger stateChanger, RabbitMQOptions mqOptions)
     : base(logger, options, connection, stateChanger)
 {
     _logger = logger;
     _connectionChannelPool = connectionChannelPool;
     _exchange        = _connectionChannelPool.Exchange;
     ServersAddress   = _connectionChannelPool.HostAddress;
     _rabbitMQOptions = mqOptions;
 }
コード例 #7
0
        public ConnectionChannelPool(ILogger <ConnectionChannelPool> logger,
                                     RabbitMQOptions options)
        {
            _logger  = logger;
            _maxSize = DefaultPoolSize;

            _connectionActivator = CreateConnection(options);
            HostAddress          = options.HostName + ":" + options.Port;
            Exchange             = options.ExchangeName;
        }
コード例 #8
0
        public RabbitMQConsumerClient(string queueName,
                                      IConnectionChannelPool connectionChannelPool,
                                      RabbitMQOptions options)
        {
            _queueName             = queueName;
            _connectionChannelPool = connectionChannelPool;
            _rabbitMQOptions       = options;
            _exchageName           = options.ExchangeName;

            InitClient();
        }
コード例 #9
0
 public PublishQueueExecutor(
     CapOptions options,
     IStateChanger stateChanger,
     IConnection connection,
     RabbitMQOptions rabbitMQOptions,
     ILogger <PublishQueueExecutor> logger)
     : base(options, stateChanger, logger)
 {
     _logger          = logger;
     _connection      = connection;
     _rabbitMQOptions = rabbitMQOptions;
 }
コード例 #10
0
        public ConnectionChannelPool(ILogger <ConnectionChannelPool> logger, RabbitMQOptions options)
        {
            _logger              = logger;
            _maxSize             = DefaultPoolSize;
            _pool                = new ConcurrentQueue <IModel>();
            _connectionActivator = CreateConnection(options);

            HostAddress = options.HostName + ":" + options.Port;
            Exchange    = options.ExchangeName;

            _logger.LogDebug("RabbitMQ configuration of CAP :\r\n {0}",
                             JsonConvert.SerializeObject(options, Formatting.Indented));
        }
コード例 #11
0
        public RabbitJobProcessor(
            IOptions <CapOptions> capOptions,
            IOptions <RabbitMQOptions> rabbitMQOptions,
            ILogger <RabbitJobProcessor> logger,
            IServiceProvider provider)
        {
            _logger          = logger;
            _rabbitMqOptions = rabbitMQOptions.Value;
            _provider        = provider;
            _cts             = new CancellationTokenSource();

            var capOptions1 = capOptions.Value;

            _pollingDelay = TimeSpan.FromSeconds(capOptions1.PollingDelay);
        }
コード例 #12
0
        private static Func <IConnection> CreateActivator(RabbitMQOptions options)
        {
            var factory = new ConnectionFactory()
            {
                HostName    = options.HostName,
                UserName    = options.UserName,
                Port        = options.Port,
                Password    = options.Password,
                VirtualHost = options.VirtualHost,
                RequestedConnectionTimeout = options.RequestedConnectionTimeout,
                SocketReadTimeout          = options.SocketReadTimeout,
                SocketWriteTimeout         = options.SocketWriteTimeout
            };

            return(() => factory.CreateConnection());
        }
コード例 #13
0
        private static Func <IConnection> CreateConnection(RabbitMQOptions options)
        {
            var factory = new ConnectionFactory
            {
                UserName    = options.UserName,
                Port        = options.Port,
                Password    = options.Password,
                VirtualHost = options.VirtualHost
            };

            if (options.HostName.Contains(","))
            {
                options.ConnectionFactoryOptions?.Invoke(factory);
                return(() => factory.CreateConnection(
                           options.HostName.Split(new[] { "," }, StringSplitOptions.RemoveEmptyEntries)));
            }

            factory.HostName = options.HostName;
            options.ConnectionFactoryOptions?.Invoke(factory);
            return(() => factory.CreateConnection());
        }
コード例 #14
0
        public ConnectionChannelPool(ILogger <ConnectionChannelPool> logger,
                                     CapOptions capOptions,
                                     RabbitMQOptions options)
        {
            _logger              = logger;
            _maxSize             = DefaultPoolSize;
            _pool                = new ConcurrentQueue <IModel>();
            _connectionActivator = CreateConnection(options);

            HostAddress = options.HostName + ":" + options.Port;

            if (CapOptions.DefaultVersion == capOptions.Version)
            {
                Exchange = options.ExchangeName;
            }
            else
            {
                Exchange = options.ExchangeName + "." + capOptions.Version;
            }

            _logger.LogDebug($"RabbitMQ configuration:'HostName:{options.HostName}, Port:{options.Port}, UserName:{options.UserName}, Password:{options.Password}, ExchangeName:{options.ExchangeName}'");
        }
コード例 #15
0
        public ConnectionChannelPool(ILogger <ConnectionChannelPool> logger,
                                     CapOptions capOptions,
                                     RabbitMQOptions options)
        {
            _logger              = logger;
            _maxSize             = DefaultPoolSize;
            _pool                = new ConcurrentQueue <IModel>();
            _connectionActivator = CreateConnection(options);

            HostAddress = options.HostName + ":" + options.Port;

            if (CapOptions.DefaultVersion == capOptions.Version)
            {
                Exchange = options.ExchangeName;
            }
            else
            {
                Exchange = options.ExchangeName + "." + capOptions.Version;
            }

            _logger.LogDebug("RabbitMQ configuration of CAP :{0} {1}", Environment.NewLine, JsonConvert.SerializeObject(options, Formatting.Indented));
        }
コード例 #16
0
        private static Func <IConnection> CreateConnection(RabbitMQOptions options)
        {
            var factory = new ConnectionFactory
            {
                UserName    = options.UserName,
                Port        = options.Port,
                Password    = options.Password,
                VirtualHost = options.VirtualHost,
                RequestedConnectionTimeout = options.RequestedConnectionTimeout,
                SocketReadTimeout          = options.SocketReadTimeout,
                SocketWriteTimeout         = options.SocketWriteTimeout
            };

            if (options.HostName.Contains(","))
            {
                return(() => factory.CreateConnection(
                           options.HostName.Split(new[] { "," }, StringSplitOptions.RemoveEmptyEntries)));
            }

            factory.HostName = options.HostName;
            return(() => factory.CreateConnection());
        }
コード例 #17
0
 public RabbitMQConsumerClientFactory(RabbitMQOptions rabbitMQOptions, IConnection connection)
 {
     _rabbitMQOptions = rabbitMQOptions;
     _connection      = connection;
 }
コード例 #18
0
 public RabbitMQConsumerClientFactory(RabbitMQOptions rabbitMQOptions, ConnectionPool pool)
 {
     _rabbitMQOptions = rabbitMQOptions;
     _connectionPool  = pool;
 }
コード例 #19
0
        public ConnectionPool(RabbitMQOptions options)
        {
            _maxSize = DefaultPoolSize;

            _activator = CreateActivator(options);
        }
コード例 #20
0
 public RabbitMQConsumerClientFactory(RabbitMQOptions rabbitMQOptions)
 {
     _rabbitMQOptions = rabbitMQOptions;
 }
コード例 #21
0
 public RabbitMQConsumerClientFactory(IOptions <RabbitMQOptions> rabbitMQOptions)
 {
     _rabbitMQOptions = rabbitMQOptions.Value;
 }