예제 #1
0
        ConnectionHandler <RabbitMqConnection> GetConnection(IRabbitMqEndpointAddress address)
        {
            return(_connectionCache.Retrieve(address.Uri, () =>
            {
                ConnectionFactoryBuilder builder = _connectionFactoryBuilders.Retrieve(address.Uri, () =>
                {
                    var configurator = new ConnectionFactoryConfiguratorImpl(address);

                    return configurator.CreateBuilder();
                });

                ConnectionFactory connectionFactory = builder.Build();

                var connection = new RabbitMqConnection(connectionFactory);
                var connectionHandler = new ConnectionHandlerImpl <RabbitMqConnection>(connection);
                return connectionHandler;
            }));
        }
        ConnectionHandler <RabbitMqConnection> GetConnection(
            Cache <ConnectionFactory, ConnectionHandler <RabbitMqConnection> > cache, IRabbitMqEndpointAddress address)
        {
            ConnectionFactory factory = SanitizeConnectionFactory(address);

            return(cache.Get(factory, _ =>
            {
                if (_log.IsDebugEnabled)
                {
                    _log.DebugFormat("Creating RabbitMQ connection: {0}", address.Uri);
                }

                ConnectionFactoryBuilder builder = _connectionFactoryBuilders.Get(factory, __ =>
                {
                    if (_log.IsDebugEnabled)
                    {
                        _log.DebugFormat("Using default configurator for connection: {0}", address.Uri);
                    }

                    var configurator = new ConnectionFactoryConfiguratorImpl(address);

                    return configurator.CreateBuilder();
                });

                ConnectionFactory connectionFactory = builder.Build();

                if (_log.IsDebugEnabled)
                {
                    _log.DebugFormat("RabbitMQ connection created: {0}:{1}/{2}", connectionFactory.HostName,
                                     connectionFactory.Port, connectionFactory.VirtualHost);
                }

                var connection = new RabbitMqConnection(connectionFactory);
                var connectionHandler = new ConnectionHandlerImpl <RabbitMqConnection>(connection);
                return connectionHandler;
            }));
        }
		ConnectionHandler<RabbitMqConnection> GetConnection(IRabbitMqEndpointAddress address)
		{
			return _connectionCache.Retrieve(address.Uri, () =>
				{
					ConnectionFactoryBuilder builder = _connectionFactoryBuilders.Retrieve(address.Uri, () =>
						{
							var configurator = new ConnectionFactoryConfiguratorImpl(address);

							return configurator.CreateBuilder();
						});

					ConnectionFactory connectionFactory = builder.Build();

					var connection = new RabbitMqConnection(connectionFactory);
					var connectionHandler = new ConnectionHandlerImpl<RabbitMqConnection>(connection);
					return connectionHandler;
				});
		}
		ConnectionHandler<RabbitMqConnection> GetConnection(IRabbitMqEndpointAddress address)
		{
			return _connectionCache.Retrieve(address.Uri, () =>
				{
					var connection = new RabbitMqConnection(address);
					var connectionHandler = new ConnectionHandlerImpl<RabbitMqConnection>(connection);
					return connectionHandler;
				});
		}