@@ -100,23 +100,7 @@ public async Task<RetryData> GetRetryData(IMessage @event)
100
100
public async Task < RedisValue [ ] > GetOldestProcessingEvents < T > ( int count ) where T : IMessage
101
101
{
102
102
var processingEventsListKey = GetProcessingEventsListKey < T > ( ) ;
103
- var listLength = await _redisClient . ListLengthAsync ( processingEventsListKey ) . ConfigureAwait ( false ) ;
104
- long startIndex ;
105
-
106
- if ( listLength == 0 )
107
- {
108
- return new RedisValue [ 0 ] ;
109
- }
110
- if ( listLength > count )
111
- {
112
- startIndex = listLength - count ;
113
- }
114
- else
115
- {
116
- startIndex = 0 ;
117
- }
118
-
119
- var unprocessedEvents = await _redisClient . ListRangeAsync ( processingEventsListKey , startIndex , - 1 ) . ConfigureAwait ( false ) ;
103
+ var unprocessedEvents = await _redisClient . ListRangeAsync ( processingEventsListKey , count * - 1 , - 1 ) . ConfigureAwait ( false ) ;
120
104
return unprocessedEvents ;
121
105
}
122
106
@@ -126,10 +110,11 @@ public async Task MoveProcessingEventToDeadLetterQueue<T>(RedisValue eventData,
126
110
var processingEventsListKey = GetProcessingEventsListKey < T > ( ) ;
127
111
var tran = _redisClient . CreateTransaction ( ) ;
128
112
129
- tran . ListLeftPushAsync ( deadLetterListKey , eventData ) ;
130
- tran . ListRemoveAsync ( processingEventsListKey , eventData , - 1 ) ;
113
+ var pushTask = tran . ListLeftPushAsync ( deadLetterListKey , eventData ) ;
114
+ var removeTask = tran . ListRemoveAsync ( processingEventsListKey , eventData , - 1 ) ;
131
115
132
116
await ExcecuteTransaction ( tran , @event . Id ) . ConfigureAwait ( false ) ;
117
+ await Task . WhenAll ( pushTask , removeTask ) . ConfigureAwait ( false ) ;
133
118
}
134
119
135
120
private string GetDeadLetterListKey < T > ( ) where T : IMessage
0 commit comments