/// <summary> /// Gets a message queue or throws an exception. /// </summary> /// <param name="messageQueuePath">The message queue path.</param> /// <returns>The message queue.</returns> /// <exception cref="Exception">If any exception occured when getting the message queue.</exception> protected IMessageQueue GetMessageQueue(string messageQueuePath) { if (!_messageQueues.ContainsKey(messageQueuePath)) { try { var messageQueue = GatewayMessageQueue.Get(messageQueuePath); LogInformation(LogEntry.Create(MessageQueueStatus.InitialisedQueue, sourceMessageQueuePath: messageQueuePath)); _messageQueues[messageQueuePath] = messageQueue; } catch (Exception e) { LogError(LogEntry.Create(MessageQueueStatus.InitialiseQueueError, sourceMessageQueuePath: messageQueuePath), e); throw; } } return(_messageQueues[messageQueuePath]); }
/// <summary> /// Clears all the queues and its corresponding dead letter queue. /// </summary> /// <param name="queuePaths">Queue paths.</param> private static void ClearQueues(params string[] queuePaths) { foreach (var path in queuePaths) { // Note that this must be the same as DequeueClientServiceBase.DeadLetterQueuePathFormat. using (var deadLetterQueue = GatewayMessageQueue.Get(DequeueServiceConfig.DeadLetterQueuePath(path))) using (var queue = GatewayMessageQueue.Get(path)) { deadLetterQueue.Clear(); queue.Clear(); } } }
/// <summary> /// Get a unique test message queue. /// </summary> /// <returns>Unique test IMessageQueue.</returns> protected static IMessageQueue GetUniqueMessageQueue() => GatewayMessageQueue.Get(GetUniqueMessageQueuePath());
/// <summary> /// Get a test message queue. /// </summary> /// <returns>Test IMessageQueue.</returns> protected static IMessageQueue GetTestMessageQueue() => GatewayMessageQueue.Get(TestQueuePath);