private void _autoScaleConsumerCatchAll_MessageReceived(object sender, MessageReceivedEventArgs e) { if (e.Message.Contains("scale-out")) { var consumer = new RabbitMQConsumerCatchAll("Math", 10); _adapter.ConsumeAsync(consumer); _consumers.Add(consumer); } else { if (_consumers.Count <= 1) { return; } var lastConsumer = _consumers[_consumers.Count - 1]; _adapter.StopConsumingAsync(lastConsumer); _consumers.RemoveAt(_consumers.Count - 1); } }
public void Shutdown() { if (_adapter == null) { return; } if (_rabbitMqConsumerCatchAll != null) { _adapter.StopConsumingAsync(_rabbitMqConsumerCatchAll); } _adapter.Disconnect(); }