diff --git a/src/DotNetCore.CAP.Kafka/KafkaConsumerClient.cs b/src/DotNetCore.CAP.Kafka/KafkaConsumerClient.cs index 5753654..2a38cbf 100644 --- a/src/DotNetCore.CAP.Kafka/KafkaConsumerClient.cs +++ b/src/DotNetCore.CAP.Kafka/KafkaConsumerClient.cs @@ -75,7 +75,7 @@ namespace DotNetCore.CAP.Kafka public void Dispose() { - _consumerClient.Dispose(); + _consumerClient?.Dispose(); } #region private methods diff --git a/src/DotNetCore.CAP.RabbitMQ/RabbitMQConsumerClient.cs b/src/DotNetCore.CAP.RabbitMQ/RabbitMQConsumerClient.cs index 953ee06..430ac20 100644 --- a/src/DotNetCore.CAP.RabbitMQ/RabbitMQConsumerClient.cs +++ b/src/DotNetCore.CAP.RabbitMQ/RabbitMQConsumerClient.cs @@ -89,8 +89,8 @@ namespace DotNetCore.CAP.RabbitMQ public void Dispose() { - _channel.Dispose(); - _connection.Dispose(); + _channel?.Dispose(); + _connection?.Dispose(); } #region events