@@ -63,10 +63,24 @@ public override Task BasicRejectAsync(ulong deliveryTag, bool requeue)
6363 return ModelSendAsync ( method , CancellationToken . None ) . AsTask ( ) ;
6464 }
6565
66+ /// <summary>
67+ /// Returning <c>true</c> from this method means that the command was server-originated,
68+ /// and handled already.
69+ /// Returning <c>false</c> (the default) means that the incoming command is the response to
70+ /// a client-initiated RPC call, and must be handled.
71+ /// </summary>
72+ /// <param name="cmd">The incoming command from the AMQP server</param>
73+ /// <param name="cancellationToken">The cancellation token</param>
74+ /// <returns></returns>
6675 protected override Task < bool > DispatchCommandAsync ( IncomingCommand cmd , CancellationToken cancellationToken )
6776 {
6877 switch ( cmd . CommandId )
6978 {
79+ case ProtocolCommandId . BasicCancel :
80+ {
81+ HandleBasicCancel ( in cmd ) ;
82+ return Task . FromResult ( true ) ;
83+ }
7084 case ProtocolCommandId . BasicDeliver :
7185 {
7286 HandleBasicDeliver ( in cmd ) ;
@@ -77,27 +91,6 @@ protected override Task<bool> DispatchCommandAsync(IncomingCommand cmd, Cancella
7791 HandleBasicAck ( in cmd ) ;
7892 return Task . FromResult ( true ) ;
7993 }
80- case ProtocolCommandId . BasicCancel :
81- {
82- HandleBasicCancel ( in cmd ) ;
83- return Task . FromResult ( true ) ;
84- }
85- case ProtocolCommandId . BasicCancelOk :
86- {
87- return Task . FromResult ( false ) ;
88- }
89- case ProtocolCommandId . BasicConsumeOk :
90- {
91- return Task . FromResult ( false ) ;
92- }
93- case ProtocolCommandId . BasicGetEmpty :
94- {
95- return Task . FromResult ( false ) ;
96- }
97- case ProtocolCommandId . BasicGetOk :
98- {
99- return Task . FromResult ( false ) ;
100- }
10194 case ProtocolCommandId . BasicNack :
10295 {
10396 HandleBasicNack ( in cmd ) ;
@@ -110,6 +103,7 @@ protected override Task<bool> DispatchCommandAsync(IncomingCommand cmd, Cancella
110103 }
111104 case ProtocolCommandId . ChannelClose :
112105 {
106+ // Note: always returns true
113107 return HandleChannelCloseAsync ( cmd , cancellationToken ) ;
114108 }
115109 case ProtocolCommandId . ChannelCloseOk :
@@ -119,6 +113,7 @@ protected override Task<bool> DispatchCommandAsync(IncomingCommand cmd, Cancella
119113 }
120114 case ProtocolCommandId . ChannelFlow :
121115 {
116+ // Note: always returns true
122117 return HandleChannelFlowAsync ( cmd , cancellationToken ) ;
123118 }
124119 case ProtocolCommandId . ConnectionBlocked :
@@ -128,6 +123,7 @@ protected override Task<bool> DispatchCommandAsync(IncomingCommand cmd, Cancella
128123 }
129124 case ProtocolCommandId . ConnectionClose :
130125 {
126+ // Note: always returns true
131127 return HandleConnectionCloseAsync ( cmd , cancellationToken ) ;
132128 }
133129 case ProtocolCommandId . ConnectionSecure :
@@ -137,6 +133,7 @@ protected override Task<bool> DispatchCommandAsync(IncomingCommand cmd, Cancella
137133 }
138134 case ProtocolCommandId . ConnectionStart :
139135 {
136+ // Note: always returns true
140137 return HandleConnectionStartAsync ( cmd , cancellationToken ) ;
141138 }
142139 case ProtocolCommandId . ConnectionTune :
@@ -149,11 +146,10 @@ protected override Task<bool> DispatchCommandAsync(IncomingCommand cmd, Cancella
149146 HandleConnectionUnblocked ( in cmd ) ;
150147 return Task . FromResult ( true ) ;
151148 }
152- case ProtocolCommandId . QueueDeclareOk :
149+ default :
153150 {
154151 return Task . FromResult ( false ) ;
155152 }
156- default : return Task . FromResult ( false ) ;
157153 }
158154 }
159155 }
0 commit comments