Пример #1
0
        public void hash_codes_for_receipt_handles_with_same_handle_value_are_always_equal()
        {
            var random = new Random((int)GlobalClock.UtcNow.Ticks);
            for(var i = 0; i < 1000; i++) {
                var sqsReceiptHandle = random.Next();
                var sqsReceiptHandleHash = new SqsMessageReceipt(sqsReceiptHandle.ToString(CultureInfo.InvariantCulture)).GetHashCode();
                var sqsReceiptHandles = Enumerable.Repeat(sqsReceiptHandle, 1000).Select(integer => integer.ToString(CultureInfo.InvariantCulture).GetHashCode()).ToArray();

                // Test that the hash codes match
                for(var j = 0; j < sqsReceiptHandles.Count(); j++) {
                    Assert.AreEqual(sqsReceiptHandleHash, sqsReceiptHandles[j], string.Format("SqsReceiptHandle '{0}' with hash '{1}', its clone did not match its hash '{2}'", sqsReceiptHandle, sqsReceiptHandleHash, sqsReceiptHandles[j]));
                }
            }
        }
Пример #2
0
        public void hash_codes_for_receipt_handles_with_same_handle_value_are_always_equal()
        {
            var random = new Random((int)GlobalClock.UtcNow.Ticks);

            for (var i = 0; i < 1000; i++)
            {
                var sqsReceiptHandle     = random.Next();
                var sqsReceiptHandleHash = new SqsMessageReceipt(sqsReceiptHandle.ToString(CultureInfo.InvariantCulture)).GetHashCode();
                var sqsReceiptHandles    = Enumerable.Repeat(sqsReceiptHandle, 1000).Select(integer => integer.ToString(CultureInfo.InvariantCulture).GetHashCode()).ToArray();

                // Test that the hash codes match
                for (var j = 0; j < sqsReceiptHandles.Count(); j++)
                {
                    Assert.AreEqual(sqsReceiptHandleHash, sqsReceiptHandles[j], string.Format("SqsReceiptHandle '{0}' with hash '{1}', its clone did not match its hash '{2}'", sqsReceiptHandle, sqsReceiptHandleHash, sqsReceiptHandles[j]));
                }
            }
        }
Пример #3
0
 /// <summary>
 /// Delete single message from named queue.
 /// </summary>
 /// <param name="queueName">Queue name.</param>
 /// <param name="messageReceipt">Message receipt.</param>
 /// <returns>True if message was deleted.</returns>
 public bool DeleteMessage(SqsQueueName queueName, SqsMessageReceipt messageReceipt)
 {
     var msgQueue = GetQueue(queueName);
     AssertQueueIsNotNull(queueName, msgQueue);
     lock(msgQueue) {
         var entry = msgQueue.FirstOrDefault(x => x.Message.MessageReceipt == messageReceipt);
         if(entry != null) {
             msgQueue.Remove(entry);
         }
     }
     return true;
 }
Пример #4
0
 public bool DeleteMessage(SqsQueueName queueName, SqsMessageReceipt messageReceipt)
 {
     _log.DebugFormat("deleting {0}", messageReceipt);
     Deleted.Add(messageReceipt);
     return true;
 }
Пример #5
0
        //--- Constructors ---

        /// <summary>
        /// Constructor for creating an instance.
        /// </summary>
        /// <param name="messageId">Message ID.</param>
        /// <param name="messageReceipt">Message receipt.</param>
        /// <param name="body">Message body.</param>
        public SqsMessage(SqsMessageId messageId, SqsMessageReceipt messageReceipt, string body)
        {
            this.MessageId      = messageId;
            this.MessageReceipt = messageReceipt;
            this.Body           = body;
        }
Пример #6
0
 /// <summary>
 /// Delete single message.
 /// </summary>
 /// <param name="messageReceipt">Message receipt.</param>
 /// <returns>True if message was deleted.</returns>
 public bool DeleteMessage(SqsMessageReceipt messageReceipt)
 {
     return _client.DeleteMessage(QueueName, messageReceipt);
 }
Пример #7
0
 //--- Constructors ---
 /// <summary>
 /// Constructor for creating an instance.
 /// </summary>
 /// <param name="messageId">Message ID.</param>
 /// <param name="messageReceipt">Message receipt.</param>
 /// <param name="body">Message body.</param>
 public SqsMessage(SqsMessageId messageId, SqsMessageReceipt messageReceipt, string body)
 {
     this.MessageId = messageId;
     this.MessageReceipt = messageReceipt;
     this.Body = body;
 }
Пример #8
0
 public bool DeleteMessage(SqsQueueName queueName, SqsMessageReceipt messageReceipt)
 {
     throw new NotImplementedException();
 }
Пример #9
0
 public bool DeleteMessage(SqsQueueName queueName, SqsMessageReceipt messageReceipt)
 {
     throw new NotImplementedException();
 }
Пример #10
0
 public bool DeleteMessage(SqsQueueName queueName, SqsMessageReceipt messageReceipt)
 {
     _log.DebugFormat("deleting {0}", messageReceipt);
     Deleted.Add(messageReceipt);
     return(true);
 }