Beispiel #1
0
 internal Task DeadletterMessageAsync(RedisMessage <T> message, int deadLetterLimit)
 {
     return(Task.WhenAll(
                _db.HashSetAsync(message.HashKey, "MaxDeliveryCountExceeded", $"DeliveryCount exceeded limit of {deadLetterLimit}"),
                _db.ListLeftPushAsync(RedisQueueConventions.GetDeadLetterQueueName(_queueName), message.RedisValue),
                _db.ListRemoveAsync(RedisQueueConventions.GetProcessingQueueName(_queueName), message.RedisValue, -1)));
 }
Beispiel #2
0
        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)));
        }
Beispiel #3
0
        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);
            }
        }
Beispiel #4
0
        internal async Task RequeueDeadletterAsync()
        {
            var deadLetterQueueName           = RedisQueueConventions.GetDeadLetterQueueName(_queueName);
            var deadLetterProcessingQueueName = RedisQueueConventions.GetProcessingQueueName(deadLetterQueueName);

            byte[] listItem = await _db.ListRightPopLeftPushAsync(deadLetterQueueName, deadLetterProcessingQueueName).ConfigureAwait(false);

            if (listItem == null)
            {
                return;
            }
            var message       = _serializer.Deserialize <RedisListItem <T> >(listItem.AsSpan());
            var hashKey       = RedisQueueConventions.GetMessageHashKey(_queueName, message.Id);
            var expirationKey = RedisQueueConventions.GetMessageExpirationKey(_queueName, message.Id);

            await _db.HashDeleteAsync(hashKey, new RedisValue[] { expirationKey, RedisHashKeys.DeliveryCount }).ConfigureAwait(false);

            await _db.ListRightPopLeftPushAsync(deadLetterProcessingQueueName, _queueName).ConfigureAwait(false);

            await _db.PublishAsync(_queueName, 0, CommandFlags.FireAndForget).ConfigureAwait(false);
        }
Beispiel #5
0
 internal Task <long> GetDeadletterMessageCount()
 {
     return(GetMessageCount(RedisQueueConventions.GetDeadLetterQueueName(_queueName)));
 }
Beispiel #6
0
 public Task DeadLetterAsync(int deadLetterLimit)
 {
     return(Task.WhenAll(
                _db.ListLeftPushAsync(RedisQueueConventions.GetDeadLetterQueueName(_queueName), _redisMessage.RedisValue),
                _db.ListRemoveAsync(RedisQueueConventions.GetProcessingQueueName(_queueName), _redisMessage.RedisValue, -1)));
 }