コード例 #1
0
        public void Bind(string exchangeName, string routingKey)
        {
            var connection = _serviceBusConnectionFactory.ResolveServiceBusConnection();
            var exchange   = _serviceBusExchangeFactory.CreateServiceBusExchange();

            exchange.CreateExchange(exchangeName, "topic");
            connection.Channel.QueueBind(Name, exchangeName, routingKey, null);
        }
コード例 #2
0
        public void CreateConnection(IServiceBusSettings serviceBusSettings, IServiceSettings serviceSettings, bool declareExchange = true)
        {
            //TODO: investigate these settings for better reliability.
            var factory = _serviceBusConnectionFactory.CreateConnectionFactory(serviceBusSettings.HostName);

            factory.AutomaticRecoveryEnabled = true;
            var connection = factory.CreateConnection();

            _connection.RegisterConnection(connection);
            _connection.ServiceSetting = serviceSettings;

            if (declareExchange)
            {
                var exchange = _serviceBusExchangeFactory.CreateServiceBusExchange();
                exchange.CreateExchange(serviceSettings.Name, "topic");
            }

            _logger.LogInformation("Connection made to rabbit MQ bus.");

            _serviceSettings.Name = serviceSettings.Name;
        }