Esempio n. 1
0
        public RabbitMqProvider(RabbitMqBackendConfig config)
        {
            _config = config;
            var amqpUri = config.AmqpUri;

            _appQueueOptions = config.ApplicationQueueConfig;


            _dialogueQueueOptions = config.DialogueQueueConfig;

            _rmqConnection = new ConnectionFactory
            {
                uri = new Uri(amqpUri),
                RequestedHeartbeat = (ushort)config.Heartbeat
            };

            // Create the primary application channel
            // Used for all subsiquent requests to AMQP
            _primaryApplicationChannel = _rmqConnection.CreateConnection();
            _primaryApplicationChannel.ConnectionShutdown += _primaryApplicationChannel_ConnectionShutdown;

            _controlChannels = new Dictionary <string, RabbitMqProducer>();
            _activeDialogues = new List <RabbitMqDialogue>();

            if (config.CheckForClosedDialogues)
            {
                _dialogueMonitor = new Timer(CheckDialogues, null, 5000, 5000);
            }
        }
        public RabbitMqProvider(RabbitMqBackendConfig config)
        {
            _config = config;
            var amqpUri = config.AmqpUri;

            _appQueueOptions = config.ApplicationQueueConfig;


            _dialogueQueueOptions = config.DialogueQueueConfig;

            _rmqConnection = new ConnectionFactory
            {
                Uri = new Uri(amqpUri),
#if NETSTANDARD
                RequestedHeartbeat = TimeSpan.FromSeconds(config.Heartbeat),
#else
                RequestedHeartbeat = (ushort)config.Heartbeat,
#endif
                AutomaticRecoveryEnabled = true,
                TopologyRecoveryEnabled  = true,
                NetworkRecoveryInterval  = TimeSpan.FromSeconds(1)
            };

            // Create the primary application channel
            // Used for all subsiquent requests to AMQP
            _primaryApplicationChannel = _rmqConnection.CreateConnection();
            _primaryApplicationChannel.ConnectionShutdown += _primaryApplicationChannel_ConnectionShutdown;

            _controlChannels = new Dictionary <string, RabbitMqProducer>();
            _activeDialogues = new List <RabbitMqDialogue>();

            if (config.CheckForClosedDialogues)
            {
                _dialogueMonitor = new Timer(CheckDialogues, null, 5000, 5000);
            }
        }