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); }
public OutboundRabbitTransport(IRabbitEndpointAddress address, PublisherConfirmSettings publisherConfirmSettings, IConnectionHandler <TransportConnection> connectionHandler, bool bindToQueue) { _address = address; _publisherConfirmSettings = publisherConfirmSettings; _connectionHandler = connectionHandler; _bindToQueue = bindToQueue; }
public InboundRabbitTransport(IRabbitEndpointAddress address, IConnectionHandler <TransportConnection> connectionHandler, bool purgeExistingMessages, IMessageNameFormatter messageNameFormatter) { _address = address; _connectionHandler = connectionHandler; _purgeExistingMessages = purgeExistingMessages; _messageNameFormatter = messageNameFormatter; }
public ProducerBinding(IRabbitEndpointAddress address, bool bindToQueue, PublisherConfirmSettings publisherConfirmSettings) { _address = address; _bindToQueue = bindToQueue; _publisherConfirmSettings = publisherConfirmSettings; if (_publisherConfirmSettings.UsePublisherConfirms) { _confirms = new ConcurrentDictionary <ulong, string>(); } }
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>(); }
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; })); }
public RabbitEndpointManagement(IRabbitEndpointAddress address, IConnection connection) { _connection = connection; }
public RabbitEndpointManagement(IRabbitEndpointAddress address) : this(address, address.ConnectionFactory.CreateConnection()) { _owned = true; }
public ConnectionFactoryBuilder(IRabbitEndpointAddress address) { _address = address; _connectionFactoryConfigurators = new List <Func <ConnectionFactory, ConnectionFactory> >(); }
public ConsumerBinding(IRabbitEndpointAddress address, bool purgeOnBind) { _address = address; _purgeOnBind = purgeOnBind; _consumerTag = NewIds.NewId.NextGuid().ToString(); }
public void BindSubscriberExchange(IRabbitEndpointAddress address, string exchangeName, bool temporary) { AddPublisherBinding(); _connectionHandler.Use(connection => _publisher.ExchangeBind(address.Name, exchangeName, false, temporary)); }
public PublisherBinding(IRabbitEndpointAddress address) { _address = address; _exchangeBindings = new HashSet <ExchangeBinding>(); _exchanges = new Dictionary <string, bool>(); }