public LoopbackRabbitMqTransport(IRabbitMqEndpointAddress address, IInboundTransport inbound, IOutboundTransport outbound) { _inbound = inbound; _outbound = outbound; _address = address; }
public OutboundRabbitMqTransport(IRabbitMqEndpointAddress address, ConnectionHandler <RabbitMqConnection> connectionHandler, bool bindToQueue) { _address = address; _connectionHandler = connectionHandler; _bindToQueue = bindToQueue; }
public OutboundRabbitMqTransport(IRabbitMqEndpointAddress address, ConnectionHandler<RabbitMqConnection> connectionHandler, bool bindToQueue) { _address = address; _connectionHandler = connectionHandler; _bindToQueue = bindToQueue; }
ConnectionFactory SanitizeConnectionFactory(IRabbitMqEndpointAddress 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 RabbitMqProducer(IRabbitMqEndpointAddress address, bool bindToQueue) { _address = address; _bindToQueue = bindToQueue; #if NET40 _confirms = new ConcurrentCache <ulong, TaskCompletionSource <bool> >(); #endif }
public InboundRabbitMqTransport(IRabbitMqEndpointAddress address, ConnectionHandler <RabbitMqConnection> connectionHandler, bool purgeExistingMessages) { _address = address; _connectionHandler = connectionHandler; _purgeExistingMessages = purgeExistingMessages; }
public void BindSubscriberExchange(IRabbitMqEndpointAddress address, string exchangeName, bool temporary) { AddPublisherBinding(); _connectionHandler.Use(connection => { _publisher.ExchangeBind(address.Name, exchangeName, false, temporary); }); }
public InboundRabbitMqTransport(IRabbitMqEndpointAddress address, ConnectionHandler<RabbitMqConnection> connectionHandler, bool purgeExistingMessages) { _address = address; _connectionHandler = connectionHandler; _purgeExistingMessages = purgeExistingMessages; }
public RabbitMqConsumer(IRabbitMqEndpointAddress address, bool purgeOnBind) { _address = address; _purgeOnBind = purgeOnBind; _consumerTag = NewId.NextGuid().ToString(); _prefetchCount = address.PrefetchCount; }
public RabbitMqProducer(IRabbitMqEndpointAddress address, bool bindToQueue) { _address = address; _bindToQueue = bindToQueue; _exchangeBindings = new HashSet <ExchangeBinding>(); _exchanges = new HashSet <string>(); #if NET40 _confirms = new ConcurrentCache <ulong, TaskCompletionSource <bool> >(); #endif }
public RabbitMqSubscriptionBinder(IServiceBus bus) { _bindings = new Dictionary<Guid, MessageName>(); _inboundTransport = bus.Endpoint.InboundTransport as InboundRabbitMqTransport; if (_inboundTransport == null) throw new ConfigurationException( "The bus must be receiving from a RabbitMQ endpoint for this interceptor to work"); _inputAddress = _inboundTransport.Address.CastAs<IRabbitMqEndpointAddress>(); _messageNameFormatter = _inboundTransport.MessageNameFormatter; }
public PublishEndpointInterceptor(IServiceBus bus) { _bus = bus; _inboundTransport = _bus.Endpoint.InboundTransport as InboundRabbitMqTransport; if (_inboundTransport == null) { throw new ConfigurationException("The bus must be receiving from a RabbitMQ endpoint for this interceptor to work"); } _address = _inboundTransport.Address.CastAs <IRabbitMqEndpointAddress>(); _added = new Dictionary <Type, UnsubscribeAction>(); }
public RabbitMqSubscriptionBinder(IServiceBus bus) { _bindings = new Dictionary <Guid, MessageName>(); _inboundTransport = bus.Endpoint.InboundTransport as InboundRabbitMqTransport; if (_inboundTransport == null) { throw new ConfigurationException( "The bus must be receiving from a RabbitMQ endpoint for this interceptor to work"); } _inputAddress = _inboundTransport.Address.CastAs <IRabbitMqEndpointAddress>(); _messageNameFormatter = _inboundTransport.MessageNameFormatter; }
void FindOrAddEndpoint(Type messageType, IRabbitMqEndpointAddress address) { var locator = new PublishEndpointSinkLocator(messageType, address); _bus.OutboundPipeline.Inspect(locator); if (locator.Found) { _added.Add(messageType, () => true); return; } IEndpoint endpoint = _bus.GetEndpoint(address.Uri); this.FastInvoke(new[] { messageType }, "CreateEndpointSink", endpoint); }
void AddEndpointForType(Type messageType) { IEnumerable <Type> types = _inboundTransport.BindExchangesForPublisher(messageType, _messageNameFormatter); foreach (Type type in types) { if (_added.ContainsKey(type)) { continue; } MessageName messageName = _messageNameFormatter.GetMessageName(type); IRabbitMqEndpointAddress messageEndpointAddress = _address.ForQueue(messageName.ToString()); FindOrAddEndpoint(type, messageEndpointAddress); } }
/// <summary> /// Finds all endpoints in the outbound pipeline and starts routing messages /// to that endpoint. /// </summary> /// <param name="messageType">type of message</param> /// <param name="address">The message endpoint address.</param> void FindOrAddEndpoint(Type messageType, IRabbitMqEndpointAddress address) { var locator = new PublishEndpointSinkLocator(messageType, address); _bus.OutboundPipeline.Inspect(locator); if (locator.Found) // there was already a subscribed endpoint { _added.Add(messageType, () => true); return; } IEndpoint endpoint = _bus.GetEndpoint(address.Uri); // otherwise, create the sink for this message type and connect the out // bound pipeline to this sink. this.FastInvoke(new[] { messageType }, "CreateEndpointSink", endpoint); }
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; })); }
/// <summary> /// Returns the endpoint for the specified message type using the default /// exchange/queue convention for naming. /// /// TODO: FIX!!! /// /// </summary> /// <param name="bus">The bus instance used to resolve the endpoint</param> /// <param name="messageType">The message type to convert to a URI</param> /// <returns>The IEndpoint instance, resolved from the service bus</returns> public static IEndpoint GetEndpoint(this IServiceBus bus, Type messageType) { var inboundTransport = bus.Endpoint.InboundTransport as InboundRabbitMqTransport; if (inboundTransport == null) { throw new ArgumentException( "The bus must be receiving from a RabbitMQ endpoint to convert message types to endpoints."); } var inputAddress = inboundTransport.Address.CastAs <IRabbitMqEndpointAddress>(); IMessageNameFormatter messageNameFormatter = inboundTransport.MessageNameFormatter; MessageName messageName = messageNameFormatter.GetMessageName(messageType); IRabbitMqEndpointAddress address = inputAddress.ForQueue(messageName.ToString()); return(bus.GetEndpoint(address.Uri)); }
void AddEndpointForType(Type messageType) { using (var management = new RabbitMqEndpointManagement(_address)) { IEnumerable <Type> types = management.BindExchangesForPublisher(messageType); foreach (Type type in types) { if (_added.ContainsKey(type)) { continue; } var messageName = new MessageName(type); IRabbitMqEndpointAddress messageEndpointAddress = _address.ForQueue(messageName.ToString()); FindOrAddEndpoint(type, messageEndpointAddress); } } }
public RabbitMqConsumer(IRabbitMqEndpointAddress address, bool purgeOnBind) { _address = address; _purgeOnBind = purgeOnBind; }
public void BindSubscriberExchange(IRabbitMqEndpointAddress address, string exchangeName) { AddPublisherBinding(); _connectionHandler.Use(connection => { _publisher.ExchangeBind(address.Name, exchangeName); }); }
public PublishEndpointSinkLocator(Type messageType, IRabbitMqEndpointAddress endpointAddress) { _endpointAddress = endpointAddress; _messageType = messageType; }
public RabbitMqEndpointManagement(IRabbitMqEndpointAddress address, IConnection connection) { _connection = connection; }
public InboundRabbitMqTransport(IRabbitMqEndpointAddress address, IConnection connection) { _address = address; _connection = connection; }
public RabbitMqEndpointManagement(IRabbitMqEndpointAddress address, IConnection connection) { _address = address; _connection = connection; }
public RabbitMqEndpointManagement(IRabbitMqEndpointAddress address) : this(address, address.ConnectionFactory.CreateConnection()) { _owned = true; }
public RabbitMqConnection(IRabbitMqEndpointAddress address) { _address = address; }
public RabbitMqPublisher(IRabbitMqEndpointAddress address) { _address = address; _exchangeBindings = new HashSet <ExchangeBinding>(); _exchanges = new Dictionary <string, bool>(); }
static void PurgeExistingMessages(ConnectionHandler<RabbitMqConnection> connectionHandler, IRabbitMqEndpointAddress address) { connectionHandler.Use(connection => { using (var management = new RabbitMqEndpointManagement(address, connection.Connection)) { management.Purge(address.Name); } }); }
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; })); }
public ConnectionFactoryBuilderImpl(IRabbitMqEndpointAddress address) { _address = address; _connectionFactoryConfigurators = new List <Func <ConnectionFactory, ConnectionFactory> >(); }
public RabbitMqSubscriptionBinder(IServiceBus bus) { _bindings = new Dictionary <Guid, MessageName>(); _inputAddress = bus.Endpoint.InboundTransport.Address.CastAs <IRabbitMqEndpointAddress>(); }
IConnection GetConnection(IRabbitMqEndpointAddress address) { return _connectionCache.Retrieve(address.Uri, () => address.ConnectionFactory.CreateConnection()); }
public RabbitMqProducer(IRabbitMqEndpointAddress address, bool bindToQueue) { _address = address; _bindToQueue = bindToQueue; }
static void BindErrorExchangeToQueue(IRabbitMqEndpointAddress address, IConnection connection) { // we need to go ahead and bind a durable queue for the error transport, since // there is probably not a listener for it. using (var management = new RabbitMqEndpointManagement(address, connection)) { management.BindQueue(address.Name, address.Name, ExchangeType.Fanout, ""); } }
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; }); }
public InboundRabbitMqTransport(IRabbitMqEndpointAddress address, ConnectionHandler<RabbitMqConnection> connectionHandler) { _address = address; _connectionHandler = connectionHandler; }
public ConnectionFactoryConfiguratorImpl(IRabbitMqEndpointAddress address) { _address = address; _configurators = new List<ConnectionFactoryBuilderConfigurator>(); }
ConnectionHandler<RabbitMqConnection> GetConnection(IRabbitMqEndpointAddress address) { return _connectionCache.Retrieve(address.Uri, () => { var connection = new RabbitMqConnection(address); var connectionHandler = new ConnectionHandlerImpl<RabbitMqConnection>(connection); return connectionHandler; }); }