Ejemplo n.º 1
0
        ConnectionFactory SanitizeConnectionFactory(IRabbitEndpointAddress address)
        {
            ConnectionFactory factory = address.ConnectionFactory;

            foreach (ConnectionFactory builder in _connectionFactoryBuilders.GetAllKeys())
            {
                if (string.Equals(factory.VirtualHost, builder.VirtualHost) &&
                    (string.Compare(factory.HostName, builder.HostName, StringComparison.OrdinalIgnoreCase) == 0) &&
                    Equals(factory.Ssl, builder.Ssl) &&
                    factory.Port == builder.Port)
                {
                    bool userNameMatch = string.IsNullOrEmpty(factory.UserName) ||
                                         string.CompareOrdinal(factory.UserName, builder.UserName) == 0;
                    bool passwordMatch = string.IsNullOrEmpty(factory.Password) ||
                                         string.CompareOrdinal(factory.UserName, builder.Password) == 0;

                    if (userNameMatch && passwordMatch)
                    {
                        return(builder);
                    }
                }
            }

            return(address.ConnectionFactory);
        }
Ejemplo n.º 2
0
 public OutboundRabbitTransport(IRabbitEndpointAddress address,
                                PublisherConfirmSettings publisherConfirmSettings,
                                IConnectionHandler <TransportConnection> connectionHandler, bool bindToQueue)
 {
     _address = address;
     _publisherConfirmSettings = publisherConfirmSettings;
     _connectionHandler        = connectionHandler;
     _bindToQueue = bindToQueue;
 }
Ejemplo n.º 3
0
 public InboundRabbitTransport(IRabbitEndpointAddress address,
                               IConnectionHandler <TransportConnection> connectionHandler,
                               bool purgeExistingMessages,
                               IMessageNameFormatter messageNameFormatter)
 {
     _address               = address;
     _connectionHandler     = connectionHandler;
     _purgeExistingMessages = purgeExistingMessages;
     _messageNameFormatter  = messageNameFormatter;
 }
Ejemplo n.º 4
0
        public ProducerBinding(IRabbitEndpointAddress address, bool bindToQueue, PublisherConfirmSettings publisherConfirmSettings)
        {
            _address     = address;
            _bindToQueue = bindToQueue;
            _publisherConfirmSettings = publisherConfirmSettings;

            if (_publisherConfirmSettings.UsePublisherConfirms)
            {
                _confirms = new ConcurrentDictionary <ulong, string>();
            }
        }
Ejemplo n.º 5
0
        public PublishEndpointInterceptor(IServiceBus bus)
        {
            _bus = bus;

            _inboundTransport = _bus.Endpoint.InboundTransport as InboundRabbitTransport;
            if (_inboundTransport == null)
            {
                throw new ConfigurationException(
                          "The bus must be receiving from a RabbitMQ endpoint for this interceptor to work");
            }

            _messageNameFormatter = _inboundTransport.MessageNameFormatter;

            _address = _inboundTransport.Address.CastAs <IRabbitEndpointAddress>();

            _added = new Dictionary <Type, UnsubscribeAction>();
        }
Ejemplo n.º 6
0
        IConnectionHandler <TransportConnection> GetConnection(
            Cache <ConnectionFactory, IConnectionHandler <TransportConnection> > cache, IRabbitEndpointAddress address)
        {
            ConnectionFactory factory = SanitizeConnectionFactory(address);

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

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

                    var configurator = new ConnectionFactoryConfigurator(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 TransportConnection(connectionFactory);
                var connectionHandler = new ConnectionHandler <TransportConnection>(connection);
                return connectionHandler;
            }));
        }
Ejemplo n.º 7
0
 public RabbitEndpointManagement(IRabbitEndpointAddress address, IConnection connection)
 {
     _connection = connection;
 }
Ejemplo n.º 8
0
 public RabbitEndpointManagement(IRabbitEndpointAddress address)
     : this(address, address.ConnectionFactory.CreateConnection())
 {
     _owned = true;
 }
Ejemplo n.º 9
0
 public ConnectionFactoryBuilder(IRabbitEndpointAddress address)
 {
     _address = address;
     _connectionFactoryConfigurators = new List <Func <ConnectionFactory, ConnectionFactory> >();
 }
Ejemplo n.º 10
0
 public ConsumerBinding(IRabbitEndpointAddress address, bool purgeOnBind)
 {
     _address     = address;
     _purgeOnBind = purgeOnBind;
     _consumerTag = NewIds.NewId.NextGuid().ToString();
 }
Ejemplo n.º 11
0
 public void BindSubscriberExchange(IRabbitEndpointAddress address, string exchangeName, bool temporary)
 {
     AddPublisherBinding();
     _connectionHandler.Use(connection => _publisher.ExchangeBind(address.Name, exchangeName, false, temporary));
 }
Ejemplo n.º 12
0
 public PublisherBinding(IRabbitEndpointAddress address)
 {
     _address          = address;
     _exchangeBindings = new HashSet <ExchangeBinding>();
     _exchanges        = new Dictionary <string, bool>();
 }