void Consumer_ConsumerFailed(object sender, EventArgs e) { consumer.ConsumerFailed -= Consumer_ConsumerFailed; consumer.Dispose(); exchange.Dispose(); invalidExchange.Dispose(); InitializeQueueConnection(); }
protected override Task ExecuteAsync(CancellationToken stoppingToken) { var consumer = new RabbitMqConsumer(_config, OnMessage); // Dispose the consumer when service is stopped stoppingToken.Register(() => consumer.Dispose()); return(Task.CompletedTask); }