public static KeepAliveMessageHandle <T> GetResilient <T>(this IQueueStorageProvider provider, string queueName, TimeSpan keepAliveAfter, int maxProcessingTrials) where T : class { var messages = provider.Get <T>(queueName, 1, keepAliveAfter + TimeSpan.FromSeconds(30), maxProcessingTrials).ToList(); if (messages.Count == 0) { return(null); } return(new KeepAliveMessageHandle <T>(messages[0], provider, keepAliveAfter, TimeSpan.FromSeconds(30))); }
public void PutGetDelete() { var message = new MyMessage(); QueueStorage.DeleteQueue(QueueName); // deleting queue on purpose // (it's slow but necessary to really validate the retry policy) QueueStorage.Put(QueueName, message); var retrieved = QueueStorage.Get <MyMessage>(QueueName, 1).First(); Assert.AreEqual(message.MyGuid, retrieved.MyGuid, "#A01"); QueueStorage.Delete(retrieved); }
/// <summary>Gets messages from a queue (derived from the message type T) with a visibility timeout of 2 hours.</summary> /// <typeparam name="T">Type of the messages.</typeparam> /// <param name="provider">Queue storage provider.</param> /// <param name="count">Maximal number of messages to be retrieved.</param> /// <param name="maxProcessingTrials"> /// Maximum number of message processing trials, before the message is considered as /// being poisonous, removed from the queue and persisted to the 'failing-messages' store. /// </param> /// <returns>Enumeration of messages, possibly empty.</returns> public static IEnumerable <T> Get <T>(this IQueueStorageProvider provider, int count, int maxProcessingTrials) { return(provider.Get <T>(GetDefaultStorageName(typeof(T)), count, new TimeSpan(2, 0, 0), maxProcessingTrials)); }
/// <summary>Gets messages from a queue with a visibility timeout of 2 hours.</summary> /// <typeparam name="T">Type of the messages.</typeparam> /// <param name="provider">Queue storage provider.</param> /// <param name="queueName">Identifier of the queue to be pulled.</param> /// <param name="count">Maximal number of messages to be retrieved.</param> /// <param name="maxProcessingTrials"> /// Maximum number of message processing trials, before the message is considered as /// being poisonous, removed from the queue and persisted to the 'failing-messages' store. /// </param> /// <returns>Enumeration of messages, possibly empty.</returns> public static IEnumerable <T> Get <T>(this IQueueStorageProvider provider, string queueName, int count, int maxProcessingTrials) { return(provider.Get <T>(queueName, count, new TimeSpan(2, 0, 0), maxProcessingTrials)); }