Пример #1
0
 public IExchangeUpdateBuilder ForExchange(string name)
 {
     _current = new ExchangeUpdateConfiguration {
         ExchangeName = name
     };
     return(this);
 }
Пример #2
0
        public Task <ExchangeUpdateResult> UpdateExchangeAsync(ExchangeUpdateConfiguration config)
        {
            var channelTask  = _channelFactory.GetChannelAsync();
            var bindingsTask = _bindingProvider.GetBindingsAsync(config.ExchangeName);

            return(Task
                   .WhenAll(channelTask, bindingsTask)
                   .ContinueWith(t =>
            {
                var channel = channelTask.Result;
                var stopWatch = Stopwatch.StartNew();
                channel.ExchangeDelete(config.ExchangeName);
                channel.ExchangeDeclare(config.ExchangeName, config.ExchangeType.ToString(), config.Durable, config.AutoDelete, config.Arguments);
                foreach (var binding in bindingsTask.Result ?? Enumerable.Empty <Binding>())
                {
                    binding.RoutingKey = config.BindingTransformer(binding.RoutingKey);
                    if (string.Equals(binding.DestinationType, QueueDestination, StringComparison.InvariantCultureIgnoreCase))
                    {
                        channel.QueueBind(binding.Destination, config.ExchangeName, binding.RoutingKey);
                    }
                }
                stopWatch.Stop();
                return new ExchangeUpdateResult
                {
                    Exchange = config,
                    Bindings = bindingsTask.Result,
                    ExecutionTime = stopWatch.Elapsed
                };
            }));
        }
Пример #3
0
 public IExchangeUpdateBuilder ExchangeForMessage <TMessage>()
 {
     _current = new ExchangeUpdateConfiguration
     {
         ExchangeName = _conventions.ExchangeNamingConvention(typeof(TMessage))
     };
     return(this);
 }
Пример #4
0
 public ITopologySelector UseConfiguration(ExchangeUpdateConfiguration configuration)
 {
     configuration.ExchangeName = _current.ExchangeName;
     Exchanges.Add(configuration);
     return(this);
 }