internal Task DeleteDeadletterAsync(RedisDeadletter <T> deadletter) { var deadletterQueueName = RedisQueueConventions.GetDeadLetterQueueName(_queueName); var hash = RedisQueueConventions.GetMessageHashKey(_queueName, deadletter.Message.Id); return(Task.WhenAll(_db.KeyDeleteAsync(hash), _db.ListRemoveAsync(deadletterQueueName, _serializer.Serialize(deadletter.Message), -1))); }
internal async IAsyncEnumerable <RedisDeadletter <T> > PeekDeadlettersAsync(int limit) { if (limit >= 1) { limit--; //0 is the first element of the list, thus 0 will return 1 } var values = await _db.ListRangeAsync(RedisQueueConventions.GetDeadLetterQueueName(_queueName), 0, limit).ConfigureAwait(false); foreach (byte[] value in values) { var deadletter = new RedisDeadletter <T> { Message = _serializer.Deserialize <RedisListItem <T> >(value.AsSpan()) }; var hash = RedisQueueConventions.GetMessageHashKey(_queueName, deadletter.Message.Id); var hashes = await _db.HashGetAllAsync(hash).ConfigureAwait(false); deadletter.HashEntries = hashes.ToStringDictionary(); yield return(deadletter); } }
public Task DeleteDeadletterAsync <T>(RedisDeadletter <T> deadletter) where T : class, IRedisMessage { var queueClient = new RedisQueueClient <T>(_db); return(queueClient.DeleteDeadletterAsync(deadletter)); }