41
41
42
42
namespace RabbitMQ . Client . Impl
43
43
{
44
- internal abstract class AsyncRpcContinuation < T > : IRpcContinuation , IDisposable
44
+ internal abstract class AsyncRpcContinuation < T > : IRpcContinuation
45
45
{
46
46
private readonly CancellationTokenSource _cancellationTokenSource ;
47
47
private readonly CancellationTokenRegistration _cancellationTokenRegistration ;
@@ -101,7 +101,7 @@ public ConfiguredTaskAwaitable<T>.ConfiguredTaskAwaiter GetAwaiter()
101
101
return _tcsConfiguredTaskAwaitable . GetAwaiter ( ) ;
102
102
}
103
103
104
- public abstract void HandleCommand ( in IncomingCommand cmd ) ;
104
+ public abstract Task HandleCommandAsync ( IncomingCommand cmd ) ;
105
105
106
106
public virtual void HandleChannelShutdown ( ShutdownEventArgs reason )
107
107
{
@@ -135,7 +135,7 @@ public ConnectionSecureOrTuneAsyncRpcContinuation(TimeSpan continuationTimeout)
135
135
{
136
136
}
137
137
138
- public override void HandleCommand ( in IncomingCommand cmd )
138
+ public override Task HandleCommandAsync ( IncomingCommand cmd )
139
139
{
140
140
try
141
141
{
@@ -156,6 +156,8 @@ public override void HandleCommand(in IncomingCommand cmd)
156
156
{
157
157
_tcs . SetException ( new InvalidOperationException ( $ "Received unexpected command of type { cmd . CommandId } !") ) ;
158
158
}
159
+
160
+ return Task . CompletedTask ;
159
161
}
160
162
finally
161
163
{
@@ -173,7 +175,7 @@ public SimpleAsyncRpcContinuation(ProtocolCommandId expectedCommandId, TimeSpan
173
175
_expectedCommandId = expectedCommandId ;
174
176
}
175
177
176
- public override void HandleCommand ( in IncomingCommand cmd )
178
+ public override Task HandleCommandAsync ( IncomingCommand cmd )
177
179
{
178
180
try
179
181
{
@@ -185,6 +187,8 @@ public override void HandleCommand(in IncomingCommand cmd)
185
187
{
186
188
_tcs . SetException ( new InvalidOperationException ( $ "Received unexpected command of type { cmd . CommandId } !") ) ;
187
189
}
190
+
191
+ return Task . CompletedTask ;
188
192
}
189
193
finally
190
194
{
@@ -205,7 +209,7 @@ public BasicCancelAsyncRpcContinuation(string consumerTag, IConsumerDispatcher c
205
209
_consumerDispatcher = consumerDispatcher ;
206
210
}
207
211
208
- public override void HandleCommand ( in IncomingCommand cmd )
212
+ public override async Task HandleCommandAsync ( IncomingCommand cmd )
209
213
{
210
214
try
211
215
{
@@ -214,7 +218,8 @@ public override void HandleCommand(in IncomingCommand cmd)
214
218
var method = new Client . Framing . Impl . BasicCancelOk ( cmd . MethodSpan ) ;
215
219
_tcs . TrySetResult ( true ) ;
216
220
Debug . Assert ( _consumerTag == method . _consumerTag ) ;
217
- _consumerDispatcher . HandleBasicCancelOk ( _consumerTag ) ;
221
+ await _consumerDispatcher . HandleBasicCancelOkAsync ( _consumerTag , CancellationToken )
222
+ . ConfigureAwait ( false ) ;
218
223
}
219
224
else
220
225
{
@@ -240,15 +245,16 @@ public BasicConsumeAsyncRpcContinuation(IBasicConsumer consumer, IConsumerDispat
240
245
_consumerDispatcher = consumerDispatcher ;
241
246
}
242
247
243
- public override void HandleCommand ( in IncomingCommand cmd )
248
+ public override async Task HandleCommandAsync ( IncomingCommand cmd )
244
249
{
245
250
try
246
251
{
247
252
if ( cmd . CommandId == ProtocolCommandId . BasicConsumeOk )
248
253
{
249
254
var method = new Client . Framing . Impl . BasicConsumeOk ( cmd . MethodSpan ) ;
250
255
_tcs . TrySetResult ( method . _consumerTag ) ;
251
- _consumerDispatcher . HandleBasicConsumeOk ( _consumer , method . _consumerTag ) ;
256
+ await _consumerDispatcher . HandleBasicConsumeOkAsync ( _consumer , method . _consumerTag , CancellationToken )
257
+ . ConfigureAwait ( false ) ;
252
258
}
253
259
else
254
260
{
@@ -272,7 +278,7 @@ public BasicGetAsyncRpcContinuation(Func<ulong, ulong> adjustDeliveryTag, TimeSp
272
278
_adjustDeliveryTag = adjustDeliveryTag ;
273
279
}
274
280
275
- public override void HandleCommand ( in IncomingCommand cmd )
281
+ public override Task HandleCommandAsync ( IncomingCommand cmd )
276
282
{
277
283
try
278
284
{
@@ -300,6 +306,8 @@ public override void HandleCommand(in IncomingCommand cmd)
300
306
{
301
307
_tcs . SetException ( new InvalidOperationException ( $ "Received unexpected command of type { cmd . CommandId } !") ) ;
302
308
}
309
+
310
+ return Task . CompletedTask ;
303
311
}
304
312
finally
305
313
{
@@ -389,7 +397,7 @@ public QueueDeclareAsyncRpcContinuation(TimeSpan continuationTimeout) : base(con
389
397
{
390
398
}
391
399
392
- public override void HandleCommand ( in IncomingCommand cmd )
400
+ public override Task HandleCommandAsync ( IncomingCommand cmd )
393
401
{
394
402
try
395
403
{
@@ -403,6 +411,8 @@ public override void HandleCommand(in IncomingCommand cmd)
403
411
{
404
412
_tcs . SetException ( new InvalidOperationException ( $ "Received unexpected command of type { cmd . CommandId } !") ) ;
405
413
}
414
+
415
+ return Task . CompletedTask ;
406
416
}
407
417
finally
408
418
{
@@ -433,7 +443,7 @@ public QueueDeleteAsyncRpcContinuation(TimeSpan continuationTimeout) : base(cont
433
443
{
434
444
}
435
445
436
- public override void HandleCommand ( in IncomingCommand cmd )
446
+ public override Task HandleCommandAsync ( IncomingCommand cmd )
437
447
{
438
448
try
439
449
{
@@ -446,6 +456,8 @@ public override void HandleCommand(in IncomingCommand cmd)
446
456
{
447
457
_tcs . SetException ( new InvalidOperationException ( $ "Received unexpected command of type { cmd . CommandId } !") ) ;
448
458
}
459
+
460
+ return Task . CompletedTask ;
449
461
}
450
462
finally
451
463
{
@@ -460,7 +472,7 @@ public QueuePurgeAsyncRpcContinuation(TimeSpan continuationTimeout) : base(conti
460
472
{
461
473
}
462
474
463
- public override void HandleCommand ( in IncomingCommand cmd )
475
+ public override Task HandleCommandAsync ( IncomingCommand cmd )
464
476
{
465
477
try
466
478
{
@@ -473,6 +485,8 @@ public override void HandleCommand(in IncomingCommand cmd)
473
485
{
474
486
_tcs . SetException ( new InvalidOperationException ( $ "Received unexpected command of type { cmd . CommandId } !") ) ;
475
487
}
488
+
489
+ return Task . CompletedTask ;
476
490
}
477
491
finally
478
492
{
0 commit comments