/// <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]);
        }
예제 #2
0
 /// <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();
             }
     }
 }
예제 #3
0
 /// <summary>
 /// Get a unique test message queue.
 /// </summary>
 /// <returns>Unique test IMessageQueue.</returns>
 protected static IMessageQueue GetUniqueMessageQueue() => GatewayMessageQueue.Get(GetUniqueMessageQueuePath());
예제 #4
0
 /// <summary>
 /// Get a test message queue.
 /// </summary>
 /// <returns>Test IMessageQueue.</returns>
 protected static IMessageQueue GetTestMessageQueue() => GatewayMessageQueue.Get(TestQueuePath);