private void RebindQueue(string routingKey) { var ctx = ContextRegistry.GetContext(); var factory = ctx.GetObject("ConnectionFactory") as IConnectionFactory; try { IAmqpAdmin amqpAdmin = new RabbitAdmin(factory); TopicExchange mktDataExchange = new TopicExchange("APP.STOCK.MARKETDATA", false, false); Spring.Messaging.Amqp.Core.Queue mktDataQueue = new Spring.Messaging.Amqp.Core.Queue("APP.STOCK.MARKETDATA"); if (!string.IsNullOrEmpty(_currentBinding)) amqpAdmin.RemoveBinding(BindingBuilder.Bind(mktDataQueue).To(mktDataExchange).With(_currentBinding)); _currentBinding = routingKey; if (!string.IsNullOrEmpty(_currentBinding)) { amqpAdmin.DeclareBinding(BindingBuilder.Bind(mktDataQueue).To(mktDataExchange).With(_currentBinding)); txtRoutingKey.Text = _currentBinding; } } catch (Exception ex) { log.ErrorFormat("Uncaught application exception.", ex); } }