public async Task <IActionResult> Index()
        {
            try
            {
                await _reader.Read();

                return(StatusCode(200));
            }
            catch (Exception ex)
            {
                _logger.LogError($"{nameof(_reader.Read)}: Ex: {ex.AllMessages()} {Environment.NewLine} Stack: {ex.StackTrace}");
                return(StatusCode(500));
            }
        }
Пример #2
0
 /// <summary>Tries to receive a message from the queue</summary>
 /// <remarks>Within a transaction you cannot receive a message that you moved to a subqueue</remarks>
 /// <param name="properties">The properties to read</param>
 /// <param name="timeout">The time allowed, defaults to infinite.  Use <see cref="F:System.TimeSpan.Zero" /> to return without waiting</param>
 /// <param name="transaction">can be NULL for no transaction, a <see cref="T:BusterWood.Msmq.QueueTransaction" />, <see cref="F:BusterWood.Msmq.QueueTransaction.Single" />, or <see cref="F:BusterWood.Msmq.QueueTransaction.Dtc" />.</param>
 /// <returns>The message, or NULL if the receive times out</returns>
 public Message Read(Properties properties = Properties.All, TimeSpan?timeout = default(TimeSpan?), QueueTransaction transaction = null)
 {
     for (;;)
     {
         var msg          = _queueReader.Read(properties | Properties.Label, timeout);
         var hash         = ComputeHash(msg);
         var existingHash = _hashByLabel[msg.Label];
         if (hash == existingHash)
         {
             Console.Error.WriteLine($"Dropping duplicate message for label '{msg.Label}'");
             continue;
         }
         _hashByLabel[msg.Label] = hash;
         return(msg);
     }
 }
        public void ShouldReturnNullWhenQueueIsEmpty()
        {
            var result = _target.Read();

            result.Should().BeNull();
        }