/// <summary> /// Enqueue a new item. /// </summary> /// <typeparam name="T">The type of message.</typeparam> /// <param name="queue">The message queue.</param> /// <param name="item">The message item.</param> /// <param name="enqueueAt">The <see cref="DateTime"/> that the item is added to the queue.</param> public static async Task Enqueue <T>(this IMessageQueue <T> queue, T item, DateTime enqueueAt) where T : class { var message = new QMessage <T> { Id = Guid.NewGuid().ToString(), Date = enqueueAt, Value = item, IsNew = true }; await queue.Enqueue(message, isPoison : false); }
/// <summary> /// Marks an existing message as poison, after three consecutive failures. /// </summary> /// <typeparam name="T">The type of message.</typeparam> /// <param name="queue">The message queue.</param> /// <param name="message">The message.</param> public static async Task MarkPoison <T>(this IMessageQueue <T> queue, QMessage <T> message) where T : class => await queue.Enqueue(message, isPoison : true);
/// <summary> /// Enqueue an existing item. /// </summary> /// <typeparam name="T">The type of message.</typeparam> /// <param name="queue">The message queue.</param> /// <param name="message">The message.</param> public static async Task ReEnqueue <T>(this IMessageQueue <T> queue, QMessage <T> message) where T : class { message.DequeueCount++; await queue.Enqueue(message, isPoison : false); }