File tree Expand file tree Collapse file tree 1 file changed +32
-0
lines changed
projects/Test/Integration Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Original file line number Diff line number Diff line change @@ -603,6 +603,38 @@ public async Task TestDeclarationOfManyAutoDeleteQueuesWithTransientConsumer()
603603 AssertRecordedQueues ( ( RabbitMQ . Client . Framing . Impl . AutorecoveringConnection ) _conn , 0 ) ;
604604 }
605605
606+ [ Fact ]
607+ public async Task TestCloseWithinEventHandler_GH1567 ( )
608+ {
609+ var tcs = new TaskCompletionSource < bool > ( TaskCreationOptions . RunContinuationsAsynchronously ) ;
610+
611+ QueueDeclareOk q = await _channel . QueueDeclareAsync ( ) ;
612+ string queueName = q . QueueName ;
613+
614+ var consumer = new AsyncEventingBasicConsumer ( _channel ) ;
615+ consumer . Received += async ( _ , eventArgs ) =>
616+ {
617+ await _channel . BasicCancelAsync ( eventArgs . ConsumerTag ) ;
618+ // await _channel.CloseAsync();
619+ // _channel.Dispose();
620+ // _channel = null;
621+ tcs . TrySetResult ( true ) ;
622+ } ;
623+
624+ await _channel . BasicConsumeAsync ( consumer , queueName , true ) ;
625+
626+ var bp = new BasicProperties ( ) ;
627+
628+ await _channel . BasicPublishAsync ( exchange : string . Empty , routingKey : queueName ,
629+ basicProperties : bp , mandatory : true , body : GetRandomBody ( 64 ) ) ;
630+
631+ Assert . True ( await tcs . Task ) ;
632+
633+ await _channel . CloseAsync ( ) ;
634+ _channel . Dispose ( ) ;
635+ _channel = null ;
636+ }
637+
606638 private static void SetException ( Exception ex , params TaskCompletionSource < bool > [ ] tcsAry )
607639 {
608640 foreach ( TaskCompletionSource < bool > tcs in tcsAry )
You can’t perform that action at this time.
0 commit comments