You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@rocketmq.apache.org by aa...@apache.org on 2023/02/28 04:39:16 UTC

[rocketmq-clients] branch master updated: Hide unnecessary method

This is an automated email from the ASF dual-hosted git repository.

aaronai pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/rocketmq-clients.git


The following commit(s) were added to refs/heads/master by this push:
     new c6eb6528 Hide unnecessary method
c6eb6528 is described below

commit c6eb6528f293ccb97529c19f11972210d739e033
Author: Aaron Ai <ya...@gmail.com>
AuthorDate: Tue Feb 28 11:32:48 2023 +0800

    Hide unnecessary method
---
 csharp/examples/ProducerBenchmark.cs               |  3 +-
 csharp/examples/ProducerDelayMessageExample.cs     | 11 +++-
 csharp/examples/ProducerFifoMessageExample.cs      |  7 ++-
 csharp/examples/ProducerNormalMessageExample.cs    |  6 ++
 .../examples/ProducerTransactionMessageExample.cs  |  7 ++-
 csharp/examples/SimpleConsumerExample.cs           |  5 +-
 csharp/rocketmq-client-csharp/Client.cs            | 22 ++++----
 csharp/rocketmq-client-csharp/ClientManager.cs     |  4 +-
 .../rocketmq-client-csharp/ClientMeterManager.cs   |  4 +-
 csharp/rocketmq-client-csharp/IClient.cs           | 66 ----------------------
 csharp/rocketmq-client-csharp/ISendReceipt.cs      | 24 ++++++++
 csharp/rocketmq-client-csharp/MessageQueue.cs      |  5 +-
 csharp/rocketmq-client-csharp/MessageView.cs       |  7 +--
 .../MetricHttpDelegatingHandler.cs                 |  4 +-
 csharp/rocketmq-client-csharp/Producer.cs          | 10 ++--
 csharp/rocketmq-client-csharp/SendReceipt.cs       |  2 +-
 csharp/rocketmq-client-csharp/Session.cs           |  4 +-
 csharp/rocketmq-client-csharp/Signature.cs         |  4 +-
 csharp/rocketmq-client-csharp/SimpleConsumer.cs    |  6 +-
 19 files changed, 84 insertions(+), 117 deletions(-)

diff --git a/csharp/examples/ProducerBenchmark.cs b/csharp/examples/ProducerBenchmark.cs
index dc5d372f..c20d6f09 100644
--- a/csharp/examples/ProducerBenchmark.cs
+++ b/csharp/examples/ProducerBenchmark.cs
@@ -25,7 +25,7 @@ using Org.Apache.Rocketmq;
 
 namespace examples
 {
-    public class ProducerBenchmark
+    public static class ProducerBenchmark
     {
         private static readonly Logger Logger = MqLogManager.Instance.GetCurrentClassLogger();
 
@@ -66,6 +66,7 @@ namespace examples
                 .SetEndpoints(endpoints)
                 .SetCredentialsProvider(credentialsProvider)
                 .Build();
+
             const string topic = "yourNormalTopic";
             // In most case, you don't need to create too many producers, single pattern is recommended.
             await using var producer = await new Producer.Builder()
diff --git a/csharp/examples/ProducerDelayMessageExample.cs b/csharp/examples/ProducerDelayMessageExample.cs
index 31a40be7..6c879bc2 100644
--- a/csharp/examples/ProducerDelayMessageExample.cs
+++ b/csharp/examples/ProducerDelayMessageExample.cs
@@ -39,14 +39,17 @@ namespace examples
                 .SetEndpoints(endpoints)
                 .SetCredentialsProvider(credentialsProvider)
                 .Build();
+
             const string topic = "yourDelayTopic";
             // In most case, you don't need to create too many producers, single pattern is recommended.
+            // Producer here will be closed automatically.
             await using var producer = await new Producer.Builder()
                 // Set the topic name(s), which is optional but recommended.
                 // It makes producer could prefetch the topic route before message publishing.
                 .SetTopics(topic)
                 .SetClientConfig(clientConfig)
                 .Build();
+
             // Define your message body.
             var bytes = Encoding.UTF8.GetBytes("foobar");
             const string tag = "yourMessageTagA";
@@ -61,11 +64,13 @@ namespace examples
                 .SetBody(bytes)
                 .SetTag(tag)
                 .SetKeys(keys)
-                .SetDeliveryTimestamp(DateTime.UtcNow + TimeSpan.FromSeconds(30)).Build();
+                .SetDeliveryTimestamp(DateTime.UtcNow + TimeSpan.FromSeconds(30))
+                .Build();
+
             var sendReceipt = await producer.Send(message);
             Logger.Info($"Send message successfully, sendReceipt={sendReceipt}");
-            // Close the producer if you don't need it anymore.
-            await producer.Shutdown();
+            // Or you could close the producer manually.
+            // await producer.DisposeAsync();
         }
     }
 }
\ No newline at end of file
diff --git a/csharp/examples/ProducerFifoMessageExample.cs b/csharp/examples/ProducerFifoMessageExample.cs
index 9a1bdf76..c0a8337d 100644
--- a/csharp/examples/ProducerFifoMessageExample.cs
+++ b/csharp/examples/ProducerFifoMessageExample.cs
@@ -40,14 +40,17 @@ namespace examples
                 .SetEndpoints(endpoints)
                 .SetCredentialsProvider(credentialsProvider)
                 .Build();
+
             const string topic = "yourFifoTopic";
             // In most case, you don't need to create too many producers, single pattern is recommended.
+            // Producer here will be closed automatically.
             await using var producer = await new Producer.Builder()
                 // Set the topic name(s), which is optional but recommended.
                 // It makes producer could prefetch the topic route before message publishing.
                 .SetTopics(topic)
                 .SetClientConfig(clientConfig)
                 .Build();
+
             // Define your message body.
             var bytes = Encoding.UTF8.GetBytes("foobar");
             const string tag = "yourMessageTagA";
@@ -65,11 +68,11 @@ namespace examples
                 .SetKeys(keys)
                 .SetMessageGroup(messageGroup)
                 .Build();
+
             var sendReceipt = await producer.Send(message);
             Logger.Info($"Send message successfully, sendReceipt={sendReceipt}");
             Thread.Sleep(9999999);
-            // Close the producer if you don't need it anymore.
-            await producer.Shutdown();
+            // await producer.DisposeAsync();
         }
     }
 }
\ No newline at end of file
diff --git a/csharp/examples/ProducerNormalMessageExample.cs b/csharp/examples/ProducerNormalMessageExample.cs
index 258886e2..db2ccd18 100644
--- a/csharp/examples/ProducerNormalMessageExample.cs
+++ b/csharp/examples/ProducerNormalMessageExample.cs
@@ -39,14 +39,17 @@ namespace examples
                 .SetEndpoints(endpoints)
                 .SetCredentialsProvider(credentialsProvider)
                 .Build();
+
             const string topic = "yourNormalTopic";
             // In most case, you don't need to create too many producers, single pattern is recommended.
+            // Producer here will be closed automatically.
             await using var producer = await new Producer.Builder()
                 // Set the topic name(s), which is optional but recommended.
                 // It makes producer could prefetch the topic route before message publishing.
                 .SetTopics(topic)
                 .SetClientConfig(clientConfig)
                 .Build();
+
             // Define your message body.
             var bytes = Encoding.UTF8.GetBytes("foobar");
             const string tag = "yourMessageTagA";
@@ -63,8 +66,11 @@ namespace examples
                 .SetTag(tag)
                 .SetKeys(keys)
                 .Build();
+
             var sendReceipt = await producer.Send(message);
             Logger.Info($"Send message successfully, sendReceipt={sendReceipt}");
+            // Or you could close the producer manually.
+            // await producer.DisposeAsync();
         }
     }
 }
\ No newline at end of file
diff --git a/csharp/examples/ProducerTransactionMessageExample.cs b/csharp/examples/ProducerTransactionMessageExample.cs
index 06cb3995..54cebcdd 100644
--- a/csharp/examples/ProducerTransactionMessageExample.cs
+++ b/csharp/examples/ProducerTransactionMessageExample.cs
@@ -49,6 +49,7 @@ namespace examples
 
             const string topic = "yourTransactionTopic";
             // In most case, you don't need to create too many producers, single pattern is recommended.
+            // Producer here will be closed automatically.
             await using var producer = await new Producer.Builder()
                 // Set the topic name(s), which is optional but recommended.
                 // It makes producer could prefetch the topic route before message publishing.
@@ -57,7 +58,6 @@ namespace examples
                 .SetTransactionChecker(new TransactionChecker())
                 .Build();
 
-            await producer.Start();
             var transaction = producer.BeginTransaction();
             // Define your message body.
             var bytes = Encoding.UTF8.GetBytes("foobar");
@@ -74,14 +74,15 @@ namespace examples
                 .SetTag(tag)
                 .SetKeys(keys)
                 .Build();
+
             var sendReceipt = await producer.Send(message, transaction);
             Logger.Info("Send transaction message successfully, messageId={}", sendReceipt.MessageId);
             // Commit the transaction.
             transaction.Commit();
             // Or rollback the transaction.
             // transaction.rollback();
-            // Close the producer if you don't need it anymore.
-            await producer.Shutdown();
+            // Or you could close the producer manually.
+            // await producer.DisposeAsync();
         }
     }
 }
\ No newline at end of file
diff --git a/csharp/examples/SimpleConsumerExample.cs b/csharp/examples/SimpleConsumerExample.cs
index c153c544..924de61d 100644
--- a/csharp/examples/SimpleConsumerExample.cs
+++ b/csharp/examples/SimpleConsumerExample.cs
@@ -39,6 +39,7 @@ namespace examples
                 .SetEndpoints(endpoints)
                 .SetCredentialsProvider(credentialsProvider)
                 .Build();
+
             // Add your subscriptions.
             const string consumerGroup = "yourConsumerGroup";
             const string topic = "yourTopic";
@@ -46,12 +47,12 @@ namespace examples
                 { { topic, new FilterExpression("*") } };
             // In most case, you don't need to create too many consumers, single pattern is recommended.
             await using var simpleConsumer = new SimpleConsumer.Builder()
-                .SetClientConfig(clientConfig).SetConsumerGroup(consumerGroup)
+                .SetClientConfig(clientConfig)
+                .SetConsumerGroup(consumerGroup)
                 .SetAwaitDuration(TimeSpan.FromSeconds(15))
                 .SetSubscriptionExpression(subscription)
                 .Build();
 
-            await simpleConsumer.Start();
             var messageViews = await simpleConsumer.Receive(16, TimeSpan.FromSeconds(15));
             foreach (var message in messageViews)
             {
diff --git a/csharp/rocketmq-client-csharp/Client.cs b/csharp/rocketmq-client-csharp/Client.cs
index 48700c33..89452600 100644
--- a/csharp/rocketmq-client-csharp/Client.cs
+++ b/csharp/rocketmq-client-csharp/Client.cs
@@ -27,7 +27,7 @@ using NLog;
 
 namespace Org.Apache.Rocketmq
 {
-    public abstract class Client : IClient
+    public abstract class Client
     {
         private static readonly Logger Logger = MqLogManager.Instance.GetCurrentClassLogger();
 
@@ -83,7 +83,7 @@ namespace Org.Apache.Rocketmq
             State = State.New;
         }
 
-        public virtual async Task Start()
+        protected virtual async Task Start()
         {
             Logger.Debug($"Begin to start the rocketmq client, clientId={ClientId}");
             ScheduleWithFixedDelay(UpdateTopicRouteCache, TopicRouteUpdateScheduleDelay, TopicRouteUpdateSchedulePeriod,
@@ -100,7 +100,7 @@ namespace Org.Apache.Rocketmq
             Logger.Debug($"Start the rocketmq client successfully, clientId={ClientId}");
         }
 
-        public virtual async Task Shutdown()
+        protected virtual async Task Shutdown()
         {
             Logger.Debug($"Begin to shutdown rocketmq client, clientId={ClientId}");
             _heartbeatCts.Cancel();
@@ -387,7 +387,7 @@ namespace Org.Apache.Rocketmq
         }
 
 
-        public grpc.Metadata Sign()
+        internal grpc.Metadata Sign()
         {
             var metadata = new grpc::Metadata();
             Signature.Sign(this, metadata);
@@ -416,26 +416,26 @@ namespace Org.Apache.Rocketmq
             }
         }
 
-        public abstract Settings GetSettings();
+        internal abstract Settings GetSettings();
 
-        public string GetClientId()
+        internal string GetClientId()
         {
             return ClientId;
         }
 
-        public ClientConfig GetClientConfig()
+        internal ClientConfig GetClientConfig()
         {
             return ClientConfig;
         }
 
-        public virtual void OnRecoverOrphanedTransactionCommand(Endpoints endpoints,
+        internal virtual void OnRecoverOrphanedTransactionCommand(Endpoints endpoints,
             Proto.RecoverOrphanedTransactionCommand command)
         {
             Logger.Warn($"Ignore orphaned transaction recovery command from remote, which is not expected, " +
                         $"clientId={ClientId}, endpoints={endpoints}");
         }
 
-        public async void OnVerifyMessageCommand(Endpoints endpoints, Proto.VerifyMessageCommand command)
+        internal async void OnVerifyMessageCommand(Endpoints endpoints, Proto.VerifyMessageCommand command)
         {
             // Only push consumer support message consumption verification.
             Logger.Warn($"Ignore verify message command from remote, which is not expected, clientId={ClientId}, " +
@@ -459,7 +459,7 @@ namespace Org.Apache.Rocketmq
             await session.WriteAsync(telemetryCommand);
         }
 
-        public async void OnPrintThreadStackTraceCommand(Endpoints endpoints,
+        internal async void OnPrintThreadStackTraceCommand(Endpoints endpoints,
             Proto.PrintThreadStackTraceCommand command)
         {
             Logger.Warn("Ignore thread stack trace printing command from remote because it is still not supported, " +
@@ -483,7 +483,7 @@ namespace Org.Apache.Rocketmq
             await session.WriteAsync(telemetryCommand);
         }
 
-        public void OnSettingsCommand(Endpoints endpoints, Proto.Settings settings)
+        internal void OnSettingsCommand(Endpoints endpoints, Proto.Settings settings)
         {
             var metric = new Metric(settings.Metric);
             ClientMeterManager.Reset(metric);
diff --git a/csharp/rocketmq-client-csharp/ClientManager.cs b/csharp/rocketmq-client-csharp/ClientManager.cs
index f464d461..c8a525a4 100644
--- a/csharp/rocketmq-client-csharp/ClientManager.cs
+++ b/csharp/rocketmq-client-csharp/ClientManager.cs
@@ -26,11 +26,11 @@ namespace Org.Apache.Rocketmq
 {
     public class ClientManager : IClientManager
     {
-        private readonly IClient _client;
+        private readonly Client _client;
         private readonly Dictionary<Endpoints, RpcClient> _rpcClients;
         private readonly ReaderWriterLockSlim _clientLock;
 
-        public ClientManager(IClient client)
+        public ClientManager(Client client)
         {
             _client = client;
             _rpcClients = new Dictionary<Endpoints, RpcClient>();
diff --git a/csharp/rocketmq-client-csharp/ClientMeterManager.cs b/csharp/rocketmq-client-csharp/ClientMeterManager.cs
index 2ac06b97..67801335 100644
--- a/csharp/rocketmq-client-csharp/ClientMeterManager.cs
+++ b/csharp/rocketmq-client-csharp/ClientMeterManager.cs
@@ -33,13 +33,13 @@ namespace Org.Apache.Rocketmq
         private const string Version = "1.0";
         private const int MetricExportPeriodInMillis = 60 * 1000;
 
-        private readonly IClient _client;
+        private readonly Client _client;
         private volatile ClientMeter _clientMeter;
         private readonly HttpClient _httpClient;
         private readonly object _lock;
         internal readonly Meter Meter;
 
-        public ClientMeterManager(IClient client)
+        public ClientMeterManager(Client client)
         {
             _client = client;
             var httpDelegatingHandler = new MetricHttpDelegatingHandler(client);
diff --git a/csharp/rocketmq-client-csharp/IClient.cs b/csharp/rocketmq-client-csharp/IClient.cs
deleted file mode 100644
index 3d20d3d5..00000000
--- a/csharp/rocketmq-client-csharp/IClient.cs
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-using System.Threading;
-using Grpc.Core;
-using Proto = Apache.Rocketmq.V2;
-
-namespace Org.Apache.Rocketmq
-{
-    public interface IClient
-    {
-        ClientConfig GetClientConfig();
-
-        Settings GetSettings();
-
-        /// <summary>
-        /// Get the identifier of current client. 
-        /// </summary>
-        /// <returns>Client identifier.</returns>
-        string GetClientId();
-
-        /// <summary>
-        /// This method will be triggered when client settings is received from remote endpoints.
-        /// </summary>
-        /// <param name="endpoints"></param>
-        /// <param name="settings"></param>
-        void OnSettingsCommand(Endpoints endpoints, Proto.Settings settings);
-
-        /// <summary>
-        /// This method will be triggered when orphaned transaction need to be recovered.
-        /// </summary>
-        /// <param name="endpoints">Remote endpoints.</param>
-        /// <param name="command">Command of orphaned transaction recovery.</param>
-        void OnRecoverOrphanedTransactionCommand(Endpoints endpoints, Proto.RecoverOrphanedTransactionCommand command);
-
-        /// <summary>
-        /// This method will be triggered when message verification command is received.
-        /// </summary>
-        /// <param name="endpoints">Remote endpoints.</param>
-        /// <param name="command">Command of message verification.</param>
-        void OnVerifyMessageCommand(Endpoints endpoints, Proto.VerifyMessageCommand command);
-
-        /// <summary>
-        /// This method will be triggered when thread stack trace command is received.
-        /// </summary>
-        /// <param name="endpoints">Remote endpoints.</param>
-        /// <param name="command">Command of printing thread stack trace.</param>
-        void OnPrintThreadStackTraceCommand(Endpoints endpoints, Proto.PrintThreadStackTraceCommand command);
-
-        Metadata Sign();
-    }
-}
\ No newline at end of file
diff --git a/csharp/rocketmq-client-csharp/ISendReceipt.cs b/csharp/rocketmq-client-csharp/ISendReceipt.cs
new file mode 100644
index 00000000..f1004b5b
--- /dev/null
+++ b/csharp/rocketmq-client-csharp/ISendReceipt.cs
@@ -0,0 +1,24 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Org.Apache.Rocketmq
+{
+    public interface ISendReceipt
+    {
+        string MessageId { get; }
+    }
+}
\ No newline at end of file
diff --git a/csharp/rocketmq-client-csharp/MessageQueue.cs b/csharp/rocketmq-client-csharp/MessageQueue.cs
index 580fbafe..b4504f12 100644
--- a/csharp/rocketmq-client-csharp/MessageQueue.cs
+++ b/csharp/rocketmq-client-csharp/MessageQueue.cs
@@ -45,10 +45,7 @@ namespace Org.Apache.Rocketmq
 
         public List<MessageType> AcceptMessageTypes { get; }
 
-        public string Topic
-        {
-            get { return TopicResource.Name; }
-        }
+        public string Topic => TopicResource.Name;
 
         public override string ToString()
         {
diff --git a/csharp/rocketmq-client-csharp/MessageView.cs b/csharp/rocketmq-client-csharp/MessageView.cs
index 21cd3677..2b5529ea 100644
--- a/csharp/rocketmq-client-csharp/MessageView.cs
+++ b/csharp/rocketmq-client-csharp/MessageView.cs
@@ -80,12 +80,7 @@ namespace Org.Apache.Rocketmq
 
         public int DeliveryAttempt { get; }
 
-        public static MessageView FromProtobuf(Proto.Message message)
-        {
-            return FromProtobuf(message, null);
-        }
-
-        public static MessageView FromProtobuf(Proto.Message message, MessageQueue messageQueue)
+        public static MessageView FromProtobuf(Proto.Message message, MessageQueue messageQueue = null)
         {
             var topic = message.Topic.Name;
             var systemProperties = message.SystemProperties;
diff --git a/csharp/rocketmq-client-csharp/MetricHttpDelegatingHandler.cs b/csharp/rocketmq-client-csharp/MetricHttpDelegatingHandler.cs
index c5705548..3cf4cc38 100644
--- a/csharp/rocketmq-client-csharp/MetricHttpDelegatingHandler.cs
+++ b/csharp/rocketmq-client-csharp/MetricHttpDelegatingHandler.cs
@@ -23,9 +23,9 @@ namespace Org.Apache.Rocketmq
 {
     public class MetricHttpDelegatingHandler : DelegatingHandler
     {
-        private readonly IClient _client;
+        private readonly Client _client;
 
-        public MetricHttpDelegatingHandler(IClient client)
+        public MetricHttpDelegatingHandler(Client client)
         {
             _client = client;
             InnerHandler = RpcClient.CreateHttpHandler();
diff --git a/csharp/rocketmq-client-csharp/Producer.cs b/csharp/rocketmq-client-csharp/Producer.cs
index c1e411a8..efdbdcbb 100644
--- a/csharp/rocketmq-client-csharp/Producer.cs
+++ b/csharp/rocketmq-client-csharp/Producer.cs
@@ -55,7 +55,7 @@ namespace Org.Apache.Rocketmq
             return _publishingTopics.Keys;
         }
 
-        public override async Task Start()
+        protected override async Task Start()
         {
             try
             {
@@ -84,7 +84,7 @@ namespace Org.Apache.Rocketmq
             GC.SuppressFinalize(this);
         }
         
-        public override async Task Shutdown()
+        protected override async Task Shutdown()
         {
             try
             {
@@ -183,7 +183,7 @@ namespace Org.Apache.Rocketmq
             throw exception!;
         }
 
-        public async Task<SendReceipt> Send(Message message)
+        public async Task<ISendReceipt> Send(Message message)
         {
             if (State.Running != State)
             {
@@ -265,12 +265,12 @@ namespace Org.Apache.Rocketmq
             }
         }
 
-        public override Settings GetSettings()
+        internal override Settings GetSettings()
         {
             return PublishingSettings;
         }
 
-        public override async void OnRecoverOrphanedTransactionCommand(Endpoints endpoints,
+        internal override async void OnRecoverOrphanedTransactionCommand(Endpoints endpoints,
             Proto.RecoverOrphanedTransactionCommand command)
         {
             var messageId = command.Message.SystemProperties.MessageId;
diff --git a/csharp/rocketmq-client-csharp/SendReceipt.cs b/csharp/rocketmq-client-csharp/SendReceipt.cs
index 1e7c61bd..13e86ec4 100644
--- a/csharp/rocketmq-client-csharp/SendReceipt.cs
+++ b/csharp/rocketmq-client-csharp/SendReceipt.cs
@@ -21,7 +21,7 @@ using Proto = Apache.Rocketmq.V2;
 
 namespace Org.Apache.Rocketmq
 {
-    public sealed class SendReceipt
+    public sealed class SendReceipt : ISendReceipt
     {
         public SendReceipt(string messageId, string transactionId, MessageQueue messageQueue)
         {
diff --git a/csharp/rocketmq-client-csharp/Session.cs b/csharp/rocketmq-client-csharp/Session.cs
index 92465291..409e67c5 100644
--- a/csharp/rocketmq-client-csharp/Session.cs
+++ b/csharp/rocketmq-client-csharp/Session.cs
@@ -36,14 +36,14 @@ namespace Org.Apache.Rocketmq
         private readonly AsyncDuplexStreamingCall<Proto::TelemetryCommand, Proto::TelemetryCommand>
             _streamingCall;
 
-        private readonly IClient _client;
+        private readonly Client _client;
         private readonly Channel<bool> _channel;
         private readonly Endpoints _endpoints;
         private readonly SemaphoreSlim _semaphore;
 
         public Session(Endpoints endpoints,
             AsyncDuplexStreamingCall<Proto::TelemetryCommand, Proto::TelemetryCommand> streamingCall,
-            IClient client)
+            Client client)
         {
             _endpoints = endpoints;
             _semaphore = new SemaphoreSlim(1);
diff --git a/csharp/rocketmq-client-csharp/Signature.cs b/csharp/rocketmq-client-csharp/Signature.cs
index 5ae8abc0..140802ca 100644
--- a/csharp/rocketmq-client-csharp/Signature.cs
+++ b/csharp/rocketmq-client-csharp/Signature.cs
@@ -25,7 +25,7 @@ namespace Org.Apache.Rocketmq
 {
     public static class Signature
     {
-        public static void Sign(IClient client, grpc::Metadata metadata)
+        public static void Sign(Client client, grpc::Metadata metadata)
         {
             var headers = Sign(client);
             foreach (var (key, value) in headers)
@@ -34,7 +34,7 @@ namespace Org.Apache.Rocketmq
             }
         }
 
-        public static Dictionary<string, string> Sign(IClient client)
+        public static Dictionary<string, string> Sign(Client client)
         {
             Dictionary<string, string> dictionary = new Dictionary<string, string>();
             var clientConfig = client.GetClientConfig();
diff --git a/csharp/rocketmq-client-csharp/SimpleConsumer.cs b/csharp/rocketmq-client-csharp/SimpleConsumer.cs
index 97fe407c..c91a0b7a 100644
--- a/csharp/rocketmq-client-csharp/SimpleConsumer.cs
+++ b/csharp/rocketmq-client-csharp/SimpleConsumer.cs
@@ -74,7 +74,7 @@ namespace Org.Apache.Rocketmq
             _subscriptionExpressions.TryRemove(topic, out _);
         }
 
-        public override async Task Start()
+        protected override async Task Start()
         {
             try
             {
@@ -103,7 +103,7 @@ namespace Org.Apache.Rocketmq
             GC.SuppressFinalize(this);
         }
 
-        public override async Task Shutdown()
+        protected override async Task Shutdown()
         {
             try
             {
@@ -147,7 +147,7 @@ namespace Org.Apache.Rocketmq
             _subscriptionRouteDataCache.TryAdd(topic, subscriptionLoadBalancer);
         }
 
-        public override Settings GetSettings()
+        internal override Settings GetSettings()
         {
             return _simpleSubscriptionSettings;
         }