コード例 #1
0
        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);
        }
コード例 #2
0
        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);
        }