Exemplo n.º 1
0
 public RedisMessageStateHandler(IConnectionMultiplexer connection, RedisConfiguration configuration, RedisMessage <T> redisMessage, int deadLetterDeliveryLimit, IDependencyInjection messageScope)
 {
     _redisMessage           = redisMessage;
     _queueClient            = new RedisQueueClient <T>(connection.GetDatabase(configuration.DatabaseId), configuration.MessageSerializer);
     DeadLetterDeliveryLimit = deadLetterDeliveryLimit;
     MessageScope            = messageScope;
 }
Exemplo n.º 2
0
        public async Task RequeueDeadlettersAsync <T>(long count) where T : class, IRedisMessage
        {
            var queueClient = new RedisQueueClient <T>(_db);

            for (var i = 0; i < count; i++)
            {
                await queueClient.RequeueDeadletterAsync();
            }
        }
Exemplo n.º 3
0
        public virtual async Task StartAsync(CancellationToken cancellationToken)
        {
            _queueClient = new RedisQueueClient <T>(ConnectionMultiplexer.GetDatabase(_redisConfiguration.DatabaseId), _serializer, _hostConfiguration.Log);
            var sub = ConnectionMultiplexer.GetSubscriber();
            await sub.SubscribeAsync(_queueName, MessageSignalReceivedHandler);

            _messagePumpTask = Task.Factory.StartNew(async() =>
            {
                while (!cancellationToken.IsCancellationRequested)
                {
                    if (!await PumpAsync(cancellationToken).ConfigureAwait(false))
                    {
                        await Delay(_pumpDelayCancellationTokenSource.Token).ConfigureAwait(false);
                    }
                }
            });
            _lostMessageService = new LostMessageBackgroundService <T>(ConnectionMultiplexer, _redisConfiguration.DatabaseId, _serializer, _hostConfiguration.Log, _settings.MessageLockTimeout, _queueName);
            _lostMessageTask    = _lostMessageService.Start(cancellationToken);
        }
Exemplo n.º 4
0
        public Task DeleteDeadletterAsync <T>(RedisDeadletter <T> deadletter) where T : class, IRedisMessage
        {
            var queueClient = new RedisQueueClient <T>(_db);

            return(queueClient.DeleteDeadletterAsync(deadletter));
        }
Exemplo n.º 5
0
        public IAsyncEnumerable <RedisDeadletter <T> > PeekDeadlettersAsync <T>(int limit) where T : class, IRedisMessage
        {
            var queueClient = new RedisQueueClient <T>(_db);

            return(queueClient.PeekDeadlettersAsync(limit));
        }
Exemplo n.º 6
0
        public Task <long> GetDeadletterMessageCount <T>() where T : class, IRedisMessage
        {
            var queueClient = new RedisQueueClient <T>(_db);

            return(queueClient.GetDeadletterMessageCount());
        }
Exemplo n.º 7
0
        public Task <long> GetMessageCount <T>() where T : class, IRedisMessage
        {
            var queueClient = new RedisQueueClient <T>(_db, _serializer);

            return(queueClient.GetMessageCount());
        }