@@ -20,7 +20,6 @@ namespace RabbitMQ.Client.Core.DependencyInjection
2020 internal sealed class QueueService : IQueueService , IDisposable
2121 {
2222 public IConnection Connection { get ; private set ; }
23-
2423 public IModel Channel { get ; private set ; }
2524
2625 public IConnection ConsumingConnection { get ; private set ; }
@@ -64,13 +63,19 @@ public void Dispose()
6463 if ( Connection != null )
6564 {
6665 Connection . CallbackException -= HandleConnectionCallbackException ;
67- Connection . ConnectionRecoveryError -= HandleConnectionRecoveryError ;
66+ if ( Connection is IAutorecoveringConnection connection )
67+ {
68+ connection . ConnectionRecoveryError -= HandleConnectionRecoveryError ;
69+ }
6870 }
6971
7072 if ( ConsumingConnection != null )
7173 {
7274 ConsumingConnection . CallbackException -= HandleConnectionCallbackException ;
73- ConsumingConnection . ConnectionRecoveryError -= HandleConnectionRecoveryError ;
75+ if ( Connection is IAutorecoveringConnection connection )
76+ {
77+ connection . ConnectionRecoveryError -= HandleConnectionRecoveryError ;
78+ }
7479 }
7580
7681 if ( Channel != null )
@@ -190,7 +195,7 @@ public void SendString(string message, string exchangeName, string routingKey, i
190195 SendString ( message , deadLetterExchange , delayedQueueName ) ;
191196 }
192197
193- public void Send ( byte [ ] bytes , IBasicProperties properties , string exchangeName , string routingKey )
198+ public void Send ( ReadOnlyMemory < byte > bytes , IBasicProperties properties , string exchangeName , string routingKey )
194199 {
195200 EnsureProducingChannelIsNotNull ( ) ;
196201 ValidateArguments ( exchangeName , routingKey ) ;
@@ -203,7 +208,7 @@ public void Send(byte[] bytes, IBasicProperties properties, string exchangeName,
203208 }
204209 }
205210
206- public void Send ( byte [ ] bytes , IBasicProperties properties , string exchangeName , string routingKey , int secondsDelay )
211+ public void Send ( ReadOnlyMemory < byte > bytes , IBasicProperties properties , string exchangeName , string routingKey , int secondsDelay )
207212 {
208213 EnsureProducingChannelIsNotNull ( ) ;
209214 ValidateArguments ( exchangeName , routingKey ) ;
@@ -230,10 +235,10 @@ public async Task SendStringAsync(string message, string exchangeName, string ro
230235 public async Task SendStringAsync ( string message , string exchangeName , string routingKey , int secondsDelay ) =>
231236 await Task . Run ( ( ) => SendString ( message , exchangeName , routingKey , secondsDelay ) ) . ConfigureAwait ( false ) ;
232237
233- public async Task SendAsync ( byte [ ] bytes , IBasicProperties properties , string exchangeName , string routingKey ) =>
238+ public async Task SendAsync ( ReadOnlyMemory < byte > bytes , IBasicProperties properties , string exchangeName , string routingKey ) =>
234239 await Task . Run ( ( ) => Send ( bytes , properties , exchangeName , routingKey ) ) . ConfigureAwait ( false ) ;
235240
236- public async Task SendAsync ( byte [ ] bytes , IBasicProperties properties , string exchangeName , string routingKey , int secondsDelay ) =>
241+ public async Task SendAsync ( ReadOnlyMemory < byte > bytes , IBasicProperties properties , string exchangeName , string routingKey , int secondsDelay ) =>
237242 await Task . Run ( ( ) => Send ( bytes , properties , exchangeName , routingKey , secondsDelay ) ) . ConfigureAwait ( false ) ;
238243
239244 IBasicProperties CreateProperties ( )
@@ -299,7 +304,10 @@ void ConfigureConnectionInfrastructure(RabbitMqConnectionOptionsContainer option
299304 if ( Connection != null )
300305 {
301306 Connection . CallbackException += HandleConnectionCallbackException ;
302- Connection . ConnectionRecoveryError += HandleConnectionRecoveryError ;
307+ if ( Connection is IAutorecoveringConnection connection )
308+ {
309+ connection . ConnectionRecoveryError += HandleConnectionRecoveryError ;
310+ }
303311 Channel = Connection . CreateModel ( ) ;
304312 Channel . CallbackException += HandleChannelCallbackException ;
305313 Channel . BasicRecoverOk += HandleChannelBasicRecoverOk ;
@@ -309,7 +317,10 @@ void ConfigureConnectionInfrastructure(RabbitMqConnectionOptionsContainer option
309317 if ( ConsumingConnection != null )
310318 {
311319 ConsumingConnection . CallbackException += HandleConnectionCallbackException ;
312- ConsumingConnection . ConnectionRecoveryError += HandleConnectionRecoveryError ;
320+ if ( Connection is IAutorecoveringConnection connection )
321+ {
322+ connection . ConnectionRecoveryError += HandleConnectionRecoveryError ;
323+ }
313324 ConsumingChannel = ConsumingConnection . CreateModel ( ) ;
314325 ConsumingChannel . CallbackException += HandleChannelCallbackException ;
315326 ConsumingChannel . BasicRecoverOk += HandleChannelBasicRecoverOk ;
0 commit comments