public RabbitMqReceiveEndpointConfigurator(IRabbitMqHost host, RabbitMqReceiveSettings settings, IConsumePipe consumePipe) : base(consumePipe) { _host = host; _settings = settings; }
public static ReceiveSettings GetReceiveSettings(this Uri address) { var hostAddress = new RabbitMqHostAddress(address); var endpointAddress = new RabbitMqEndpointAddress(hostAddress, address); var topologyConfiguration = new RabbitMqTopologyConfiguration(RabbitMqBusFactory.MessageTopology); var endpointConfiguration = new RabbitMqEndpointConfiguration(topologyConfiguration); var settings = new RabbitMqReceiveSettings(endpointConfiguration, endpointAddress.Name, endpointAddress.ExchangeType, endpointAddress.Durable, endpointAddress.AutoDelete) { QueueName = endpointAddress.Name, Exclusive = endpointAddress.AutoDelete && !endpointAddress.Durable }; if (hostAddress.Prefetch.HasValue) { settings.PrefetchCount = hostAddress.Prefetch.Value; } if (hostAddress.TimeToLive.HasValue) { settings.QueueArguments.Add(Headers.XMessageTTL, hostAddress.TimeToLive.Value.ToString("F0", CultureInfo.InvariantCulture)); } return(settings); }
public RabbitMqBusBuilder(RabbitMqHost[] hosts, IConsumePipeSpecification consumePipeSpecification, RabbitMqReceiveSettings busSettings) : base(consumePipeSpecification, hosts) { _hosts = hosts; _busEndpointConfigurator = new RabbitMqReceiveEndpointConfigurator(_hosts[0], busSettings, ConsumePipe); }
public RabbitMqBusBuilder(RabbitMqHost[] hosts, IConsumePipeFactory consumePipeFactory, ISendPipeFactory sendPipeFactory, IPublishPipeFactory publishPipeFactory, RabbitMqReceiveSettings busSettings) : base(consumePipeFactory, sendPipeFactory, publishPipeFactory, hosts) { _hosts = hosts; _busEndpointConfigurator = new RabbitMqReceiveEndpointConfigurator(_hosts[0], busSettings, ConsumePipe); }
public RabbitMqReceiveEndpointConfiguration(IRabbitMqHostConfiguration hostConfiguration, string queueName, IRabbitMqEndpointConfiguration endpointConfiguration) : this(hostConfiguration, endpointConfiguration) { BindMessageExchanges = true; _settings = new RabbitMqReceiveSettings(queueName, endpointConfiguration.Topology.Consume.ExchangeTypeSelector.DefaultExchangeType, true, false); }
public RabbitMqReceiveEndpointSpecification(IRabbitMqHost host, RabbitMqReceiveSettings settings, IConsumePipe consumePipe) : base(consumePipe) { _host = host; _settings = settings; _managementPipe = new ManagementPipe(); _exchangeBindings = new List <ExchangeBindingSettings>(); }
public RabbitMqBusBuilder(IEnumerable<RabbitMqHost> hosts, IConsumePipeSpecification consumePipeSpecification, RabbitMqReceiveSettings busSettings) : base(consumePipeSpecification) { _hosts = hosts.ToArray(); _busConsumePipe = CreateConsumePipe(); _busEndpointConfigurator = new RabbitMqReceiveEndpointConfigurator(_hosts[0], busSettings, _busConsumePipe); }
public RabbitMqReceiveEndpointConfigurator(IRabbitMqHost host, RabbitMqReceiveSettings settings, IConsumePipe consumePipe) : base(consumePipe) { _host = host; _settings = settings; _mediator = new Mediator <ISetPrefetchCount>(); _exchangeBindings = new List <ExchangeBindingSettings>(); }
public RabbitMqReceiveEndpointSpecification(IRabbitMqHost host, IRabbitMqEndpointConfiguration configuration, RabbitMqReceiveSettings settings) : base(configuration) { _host = host; _configuration = configuration; _settings = settings; _managementPipe = new ManagementPipe(); }
public RabbitMqReceiveEndpointConfigurator(IRabbitMqHost host, RabbitMqReceiveSettings settings, IConsumePipe consumePipe) : base(consumePipe) { _host = host; _settings = settings; _mediator = new Mediator<ISetPrefetchCount>(); _exchangeBindings = new List<ExchangeBindingSettings>(); }
public RabbitMqReceiveEndpointConfigurator(IRabbitMqHost host, string queueName = null, IConsumePipe consumePipe = null) : base(consumePipe) { _host = host; _settings = new RabbitMqReceiveSettings { QueueName = queueName, ExchangeName = queueName }; }
public RabbitMqBusFactoryConfigurator(IRabbitMqBusConfiguration configuration, IRabbitMqEndpointConfiguration busEndpointConfiguration) : base(configuration, busEndpointConfiguration) { _configuration = configuration; _busEndpointConfiguration = busEndpointConfiguration; var queueName = busEndpointConfiguration.Topology.Consume.CreateTemporaryQueueName("bus-"); _settings = new RabbitMqReceiveSettings(queueName, busEndpointConfiguration.Topology.Consume.ExchangeTypeSelector.DefaultExchangeType, false, true); _settings.AutoDeleteAfter(TimeSpan.FromMinutes(1)); }
public RabbitMqBusBuilder(RabbitMqHost[] hosts, IConsumePipeFactory consumePipeFactory, ISendPipeFactory sendPipeFactory, IPublishPipeFactory publishPipeFactory, RabbitMqReceiveSettings busSettings, ModelSettings modelSettings) : base(consumePipeFactory, sendPipeFactory, publishPipeFactory, hosts) { _hosts = hosts; _modelSettings = modelSettings; _autoDeleteCacheTimeout = TimeSpan.FromMinutes(1); _sendEndpointCacheTimeout = TimeSpan.FromDays(1); _busEndpointConfigurator = new RabbitMqReceiveEndpointConfigurator(_hosts[0], busSettings, ConsumePipe); }
public RabbitMqBusFactoryConfigurator(IRabbitMqEndpointConfiguration configuration) : base(configuration) { _configuration = configuration; _hosts = new BusHostCollection <RabbitMqHost>(); var queueName = _configuration.Topology.Consume.CreateTemporaryQueueName("bus-"); _settings = new RabbitMqReceiveSettings(queueName, "fanout", false, true); _settings.SetQueueArgument("x-expires", TimeSpan.FromMinutes(1)); _settings.SetExchangeArgument("x-expires", TimeSpan.FromMinutes(1)); }
public RabbitMqReceiveEndpointConfigurator(IRabbitMqHost host, string queueName = null, IConsumePipe consumePipe = null) : base(consumePipe) { _host = host; _settings = new RabbitMqReceiveSettings { QueueName = queueName, }; _mediator = new Mediator <ISetPrefetchCount>(); _exchangeBindings = new List <ExchangeBindingSettings>(); }
public RabbitMqReceiveEndpointConfigurator(IRabbitMqHost host, string queueName = null, IConsumePipe consumePipe = null) : base(consumePipe) { _host = host; _settings = new RabbitMqReceiveSettings { QueueName = queueName, }; _mediator = new Mediator<ISetPrefetchCount>(); _exchangeBindings = new List<ExchangeBindingSettings>(); }
async Task IFilter <ModelContext> .Send(ModelContext context, IPipe <ModelContext> next) { await context.BasicQos(0, _prefetchCount, true).ConfigureAwait(false); var queueOk = await context.QueueDeclare(_settings.QueueName, _settings.Durable, _settings.Exclusive, _settings.AutoDelete, _settings.QueueArguments).ConfigureAwait(false); var queueName = queueOk.QueueName; if (_log.IsDebugEnabled) { _log.DebugFormat("Queue: {0} ({1})", queueName, string.Join(", ", new[] { _settings.Durable ? "durable" : "", _settings.Exclusive ? "exclusive" : "", _settings.AutoDelete ? "auto-delete" : "" }.Where(x => !string.IsNullOrWhiteSpace(x)))); } if (_settings.PurgeOnStartup) { await PurgeIfRequested(context, queueOk, queueName).ConfigureAwait(false); } var exchangeName = _settings.ExchangeName ?? queueName; if (!string.IsNullOrWhiteSpace(exchangeName)) { await context.ExchangeDeclare(exchangeName, _settings.ExchangeType, _settings.Durable, _settings.AutoDelete, _settings.ExchangeArguments).ConfigureAwait(false); await context.QueueBind(queueName, exchangeName, "", new Dictionary <string, object>()).ConfigureAwait(false); } await ApplyExchangeBindings(context, exchangeName).ConfigureAwait(false); ReceiveSettings settings = new RabbitMqReceiveSettings(_settings) { QueueName = queueName, ExchangeName = exchangeName }; context.GetOrAddPayload(() => settings); using (new SetModelPrefetchCountProxy(_prefetchCountMediator, context, this)) { await next.Send(context).ConfigureAwait(false); } }
public RabbitMqReceiveEndpointSpecification(IRabbitMqHost host, IRabbitMqEndpointConfiguration configuration, string queueName = null) : base(configuration) { _host = host; _configuration = configuration; _bindMessageExchanges = true; _settings = new RabbitMqReceiveSettings(queueName, configuration.Topology.Consume.ExchangeTypeSelector.DefaultExchangeType, true, false) { QueueName = queueName }; _managementPipe = new ManagementPipe(); }
public RabbitMqReceiveEndpointConfigurator(IRabbitMqHost host, string queueName = null, IConsumePipe consumePipe = null) : base(consumePipe) { _host = host; _bindMessageExchanges = true; _settings = new RabbitMqReceiveSettings { QueueName = queueName, }; _managementPipe = new ManagementPipe(); _exchangeBindings = new List <ExchangeBindingSettings>(); }
public RabbitMqBusBuilder(BusHostCollection<RabbitMqHost> hosts, IConsumePipeFactory consumePipeFactory, ISendPipeFactory sendPipeFactory, IPublishPipeFactory publishPipeFactory, RabbitMqReceiveSettings busSettings) : base(consumePipeFactory, sendPipeFactory, publishPipeFactory, hosts) { _hosts = hosts; _busEndpointSpecification = new RabbitMqReceiveEndpointSpecification(_hosts[0], busSettings, ConsumePipe); foreach (var host in hosts.Hosts) { var factory = new RabbitMqReceiveEndpointFactory(this, host); host.ReceiveEndpointFactory = factory; } }
public RabbitMqBusBuilder(BusHostCollection <RabbitMqHost> hosts, IConsumePipeFactory consumePipeFactory, ISendPipeFactory sendPipeFactory, IPublishPipeFactory publishPipeFactory, RabbitMqReceiveSettings busSettings) : base(consumePipeFactory, sendPipeFactory, publishPipeFactory, hosts) { _hosts = hosts; _busEndpointSpecification = new RabbitMqReceiveEndpointSpecification(_hosts[0], busSettings, ConsumePipe); foreach (var host in hosts.Hosts) { var factory = new RabbitMqReceiveEndpointFactory(this, host); host.ReceiveEndpointFactory = factory; } }
public RabbitMqBusFactoryConfigurator() { _hosts = new List<RabbitMqHost>(); _transportBuilderConfigurators = new List<IBusFactorySpecification>(); string queueName = this.GetTemporaryQueueName("bus-"); _settings = new RabbitMqReceiveSettings { QueueName = queueName, AutoDelete = true, Durable = false }; _settings.QueueArguments["x-expires"] = 60000; _settings.ExchangeArguments["x-expires"] = 60000; }
public RabbitMqBusFactoryConfigurator() { _hosts = new BusHostCollection <RabbitMqHost>(); var queueName = ((IRabbitMqHost)null).GetTemporaryQueueName("bus-"); _settings = new RabbitMqReceiveSettings { QueueName = queueName, AutoDelete = true, Durable = false }; _settings.QueueArguments["x-expires"] = 60000; _settings.ExchangeArguments["x-expires"] = 60000; }
public void Bind(string exchangeName, Action <IExchangeBindingConfigurator> callback) { if (exchangeName == null) { throw new ArgumentNullException(nameof(exchangeName)); } if (callback == null) { throw new ArgumentNullException(nameof(callback)); } var exchangeSettings = new RabbitMqReceiveSettings(_settings); callback(exchangeSettings); _exchangeBindings.AddRange(exchangeSettings.GetExchangeBindings(exchangeName)); }
public RabbitMqBusFactoryConfigurator() { _hosts = new List <RabbitMqHost>(); _transportBuilderConfigurators = new List <IBusFactorySpecification>(); string queueName = this.GetTemporaryQueueName("bus-"); _settings = new RabbitMqReceiveSettings { QueueName = queueName, AutoDelete = true, Durable = false }; _settings.QueueArguments["x-expires"] = 60000; _settings.ExchangeArguments["x-expires"] = 60000; }
public RabbitMqBusBuilder(BusHostCollection <RabbitMqHost> hosts, RabbitMqReceiveSettings busSettings, IRabbitMqEndpointConfiguration configuration) : base(hosts, configuration) { _hosts = hosts; var endpointConfiguration = configuration.CreateNewConfiguration(ConsumePipe); _busEndpointSpecification = new RabbitMqReceiveEndpointSpecification(_hosts[0], endpointConfiguration, busSettings); foreach (var host in hosts.Hosts) { var factory = new RabbitMqReceiveEndpointFactory(this, host, configuration); host.ReceiveEndpointFactory = factory; } }
public RabbitMqReceiveEndpointConfiguration(IRabbitMqHostConfiguration hostConfiguration, RabbitMqReceiveSettings settings, IRabbitMqEndpointConfiguration endpointConfiguration) : base(endpointConfiguration) { _hostConfiguration = hostConfiguration; _settings = settings; _endpointConfiguration = endpointConfiguration; BindMessageExchanges = true; _managementPipe = new ManagementPipe(); _connectionConfigurator = new PipeConfigurator <ConnectionContext>(); _modelConfigurator = new PipeConfigurator <ModelContext>(); _inputAddress = new Lazy <Uri>(FormatInputAddress); }
public static ReceiveSettings GetReceiveSettings(this Uri address) { var hostAddress = new RabbitMqHostAddress(address); var endpointAddress = new RabbitMqEndpointAddress(hostAddress, address); ReceiveSettings settings = new RabbitMqReceiveSettings(endpointAddress.Name, endpointAddress.ExchangeType, endpointAddress.Durable, endpointAddress.AutoDelete) { QueueName = endpointAddress.Name, PrefetchCount = hostAddress.Prefetch ?? (ushort)(Environment.ProcessorCount * 2), Exclusive = endpointAddress.AutoDelete && !endpointAddress.Durable }; if (hostAddress.TimeToLive.HasValue) { settings.QueueArguments.Add(Headers.XMessageTTL, hostAddress.TimeToLive.Value.ToString("F0", CultureInfo.InvariantCulture)); } return(settings); }
public RabbitMqReceiveEndpointConfiguration(IRabbitMqHostConfiguration hostConfiguration, RabbitMqReceiveSettings settings, IRabbitMqEndpointConfiguration endpointConfiguration) : base(hostConfiguration, endpointConfiguration) { _hostConfiguration = hostConfiguration; _settings = settings; _endpointConfiguration = endpointConfiguration; _managementPipe = new ManagementPipe(); _connectionConfigurator = new PipeConfigurator <ConnectionContext>(); _modelConfigurator = new PipeConfigurator <ModelContext>(); _inputAddress = new Lazy <Uri>(FormatInputAddress); if (settings.QueueName == RabbitMqExchangeNames.ReplyTo) { settings.ExchangeName = null; settings.BindQueue = true; settings.NoAck = true; } }
public static ReceiveSettings GetReceiveSettings(this Uri address) { if (string.Compare("rabbitmq", address.Scheme, StringComparison.OrdinalIgnoreCase) != 0) { throw new RabbitMqAddressException("The invalid scheme was specified: " + address.Scheme); } var connectionFactory = new ConnectionFactory { HostName = address.Host, UserName = "******", Password = "******", }; if (address.IsDefaultPort) { connectionFactory.Port = 5672; } else if (!address.IsDefaultPort) { connectionFactory.Port = address.Port; } string name = address.AbsolutePath.Substring(1); string[] pathSegments = name.Split('/'); if (pathSegments.Length == 2) { connectionFactory.VirtualHost = Uri.UnescapeDataString(pathSegments[0]); name = pathSegments[1]; } ushort heartbeat = address.Query.GetValueFromQueryString("heartbeat", connectionFactory.RequestedHeartbeat); connectionFactory.RequestedHeartbeat = heartbeat; if (name == "*") { string uri = address.GetComponents(UriComponents.Scheme | UriComponents.StrongAuthority | UriComponents.Path, UriFormat.UriEscaped); if (uri.EndsWith("*")) { name = NewId.Next().ToString("NS"); uri = uri.Remove(uri.Length - 1) + name; var builder = new UriBuilder(uri) { Query = string.IsNullOrEmpty(address.Query) ? "" : address.Query.Substring(1) }; address = builder.Uri; } else { throw new InvalidOperationException("Uri is not properly formed"); } } else { VerifyQueueOrExchangeNameIsLegal(name); } ushort prefetch = address.Query.GetValueFromQueryString("prefetch", (ushort)Math.Max(Environment.ProcessorCount, 16)); int timeToLive = address.Query.GetValueFromQueryString("ttl", 0); bool isTemporary = address.Query.GetValueFromQueryString("temporary", false); bool durable = address.Query.GetValueFromQueryString("durable", !isTemporary); bool exclusive = address.Query.GetValueFromQueryString("exclusive", isTemporary); bool autoDelete = address.Query.GetValueFromQueryString("autodelete", isTemporary); ReceiveSettings settings = new RabbitMqReceiveSettings(name, ExchangeType.Fanout, durable, autoDelete) { Exclusive = exclusive, QueueName = name, PrefetchCount = prefetch, }; if (timeToLive > 0) { settings.QueueArguments.Add("x-message-ttl", timeToLive.ToString("F0", CultureInfo.InvariantCulture)); } return(settings); }
public IRabbitMqReceiveEndpointConfiguration CreateReceiveEndpointConfiguration(string queueName) { var settings = new RabbitMqReceiveSettings(queueName, _busConfiguration.Topology.Consume.ExchangeTypeSelector.DefaultExchangeType, true, false); return(new RabbitMqReceiveEndpointConfiguration(this, settings, _busConfiguration.CreateEndpointConfiguration())); }
public RabbitMqReceiveEndpointConfiguration(IRabbitMqHostConfiguration hostConfiguration, RabbitMqReceiveSettings settings, IRabbitMqEndpointConfiguration endpointConfiguration) : this(hostConfiguration, endpointConfiguration) { _settings = settings; }
public RabbitMqBusBuilder(IEnumerable <RabbitMqHost> hosts, IConsumePipeSpecification consumePipeSpecification, RabbitMqReceiveSettings busSettings) : base(consumePipeSpecification) { _hosts = hosts.ToArray(); _busConsumePipe = CreateConsumePipe(); _busEndpointConfigurator = new RabbitMqReceiveEndpointConfigurator(_hosts[0], busSettings, _busConsumePipe); }
public IRabbitMqReceiveEndpointConfiguration CreateReceiveEndpointConfiguration(RabbitMqReceiveSettings settings, IRabbitMqEndpointConfiguration endpointConfiguration) { if (_hosts.Count == 0) { throw new ConfigurationException("At least one host must be configured"); } return(new RabbitMqReceiveEndpointConfiguration(_hosts[0], settings, endpointConfiguration)); }
public void Bind(string exchangeName, Action<IExchangeBindingConfigurator> callback) { if (exchangeName == null) throw new ArgumentNullException(nameof(exchangeName)); if (callback == null) throw new ArgumentNullException(nameof(callback)); var exchangeSettings = new RabbitMqReceiveSettings(_settings); callback(exchangeSettings); _exchangeBindings.AddRange(exchangeSettings.GetExchangeBindings(exchangeName)); }
public static ReceiveSettings GetReceiveSettings(this Uri address) { if (string.Compare("rabbitmq", address.Scheme, StringComparison.OrdinalIgnoreCase) != 0) throw new RabbitMqAddressException("The invalid scheme was specified: " + address.Scheme); var connectionFactory = new ConnectionFactory { HostName = address.Host, UserName = "******", Password = "******", }; if (address.IsDefaultPort) connectionFactory.Port = 5672; else if (!address.IsDefaultPort) connectionFactory.Port = address.Port; string name = address.AbsolutePath.Substring(1); string[] pathSegments = name.Split('/'); if (pathSegments.Length == 2) { connectionFactory.VirtualHost = pathSegments[0]; name = pathSegments[1]; } ushort heartbeat = address.Query.GetValueFromQueryString("heartbeat", connectionFactory.RequestedHeartbeat); connectionFactory.RequestedHeartbeat = heartbeat; if (name == "*") { string uri = address.GetLeftPart(UriPartial.Path); if (uri.EndsWith("*")) { name = NewId.Next().ToString("NS"); uri = uri.Remove(uri.Length - 1) + name; var builder = new UriBuilder(uri); builder.Query = string.IsNullOrEmpty(address.Query) ? "" : address.Query.Substring(1); address = builder.Uri; } else throw new InvalidOperationException("Uri is not properly formed"); } else VerifyQueueOrExchangeNameIsLegal(name); ushort prefetch = address.Query.GetValueFromQueryString("prefetch", (ushort)Math.Max(Environment.ProcessorCount, 16)); int timeToLive = address.Query.GetValueFromQueryString("ttl", 0); bool isTemporary = address.Query.GetValueFromQueryString("temporary", false); bool durable = address.Query.GetValueFromQueryString("durable", !isTemporary); bool exclusive = address.Query.GetValueFromQueryString("exclusive", isTemporary); bool autoDelete = address.Query.GetValueFromQueryString("autodelete", isTemporary); ReceiveSettings settings = new RabbitMqReceiveSettings { AutoDelete = autoDelete, Durable = durable, Exclusive = exclusive, QueueName = name, PrefetchCount = prefetch, }; if (timeToLive > 0) settings.QueueArguments.Add("x-message-ttl", timeToLive.ToString("F0", CultureInfo.InvariantCulture)); return settings; }