private void CheckMissingQueues() { var now = DateTimeOffset.Now.ToUnixTimeMilliseconds(); if (now - RetryDeclarationInterval > LastRetryDeclaration) { lock (MissingQueues) { List <string> toRemove = new List <string>(); Exception error = null; foreach (var queueToCheck in MissingQueues) { bool available = true; IConnection connection = null; RC.IModel channelForCheck = null; try { channelForCheck = ConnectionFactory.CreateConnection().CreateChannel(false); channelForCheck.QueueDeclarePassive(queueToCheck); Logger?.LogInformation("Queue '{queue}' is now available", queueToCheck); } catch (Exception e) { available = false; Logger?.LogWarning(e, "Queue '{queue}' is not available", queueToCheck); } finally { RabbitUtils.CloseChannel(channelForCheck); RabbitUtils.CloseConnection(connection); } if (available) { try { ConsumeFromQueue(queueToCheck); toRemove.Add(queueToCheck); } catch (Exception e) { error = e; break; } } } if (toRemove.Count > 0) { foreach (var remove in toRemove) { MissingQueues.Remove(remove); } } if (error != null) { throw RabbitExceptionTranslator.ConvertRabbitAccessException(error); } } LastRetryDeclaration = now; } }