public ConnectionProducerPool(ActiveMQOptions options, ILogger <ConnectionProducerPool> logger, CapOptions capOptions)
        {
            _logger              = logger;
            _maxSize             = DefaultPoolSize;
            _connectionActivator = CreateConnection(options);
            HostAddress          = options.BrokerUri;
            Exchange             = CapOptions.DefaultVersion == capOptions.Version ? options.TopicName : $"{options.TopicName}.{capOptions.Version}";
            _pool = new ConcurrentQueue <IMessageProducer>();

            _logger.LogDebug("ActiveMQ configuration of CAP :\r\n {0}", JsonConvert.SerializeObject(options, Formatting.Indented));
        }
示例#2
0
        public ActiveMQConsumerClient(string queueName, IConnectionProducerPool connectionProducerPool, ActiveMQOptions options)
        {
            _queueName = queueName;
            _connectionProducerPool = connectionProducerPool;
            _exchangeName           = connectionProducerPool.Exchange;
            _activeMqOptions        = options;
            _messageConsumers       = new List <IMessageConsumer>();
            _topicPrefix            = $"Consumer.{_queueName.Replace(".", "_")}.VirtualTopic.";
            _msgDic = new ConcurrentDictionary <MessageContext, ActiveMQBytesMessage>();

            InitClient();
        }
        private static Func <IConnection> CreateConnection(ActiveMQOptions options)
        {
            var factory = new ConnectionFactory
            {
                UserName       = options.UserName,
                Password       = options.Password,
                RequestTimeout = options.RequestTimeout,
                BrokerUri      = URISupport.CreateCompatibleUri(options.BrokerUri),
            };

            return(() => factory.CreateConnection());
        }
        public void AddServices(IServiceCollection services)
        {
            services.AddSingleton <CapMessageQueueMakerService>();

            var options = new ActiveMQOptions();

            _configure?.Invoke(options);
            services.AddSingleton(options);

            services.AddSingleton <IConsumerClientFactory, ActiveMQConsumerClientFactory>();
            services.AddSingleton <IConnectionProducerPool, ConnectionProducerPool>();
            services.AddSingleton <IPublishExecutor, ActiveMQPublishMessageSender>();
            services.AddSingleton <IPublishMessageSender, ActiveMQPublishMessageSender>();
        }
示例#5
0
 public ActiveMQConsumerClientFactory(IConnectionProducerPool connectionProducerPool, ActiveMQOptions activeMqOptions)
 {
     _connectionProducerPool = connectionProducerPool;
     _activeMqOptions        = activeMqOptions;
 }