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 2022/12/20 02:20:04 UTC
[rocketmq-clients] 01/04: Align ClientId generation in dotnet driver with others
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
commit 334df3ff99634113cf475c4fa8a66baa95f9773f
Author: colprog <co...@gmail.com>
AuthorDate: Thu Dec 15 03:59:28 2022 +0800
Align ClientId generation in dotnet driver with others
---
csharp/rocketmq-client-csharp/ClientConfig.cs | 11 +++--------
1 file changed, 3 insertions(+), 8 deletions(-)
diff --git a/csharp/rocketmq-client-csharp/ClientConfig.cs b/csharp/rocketmq-client-csharp/ClientConfig.cs
index 86175a2a..bdba0284 100644
--- a/csharp/rocketmq-client-csharp/ClientConfig.cs
+++ b/csharp/rocketmq-client-csharp/ClientConfig.cs
@@ -16,6 +16,7 @@
*/
using System;
using System.Collections.Generic;
+using System.Threading;
using rmq = Apache.Rocketmq.V2;
namespace Org.Apache.Rocketmq
@@ -23,12 +24,13 @@ namespace Org.Apache.Rocketmq
public class ClientConfig : IClientConfig
{
+ private static long instanceSequence = 0;
public ClientConfig()
{
var hostName = System.Net.Dns.GetHostName();
var pid = System.Diagnostics.Process.GetCurrentProcess().Id;
- this.clientId_ = string.Format("{0}@{1}#{2}", hostName, pid, instanceName_);
+ this.clientId_ = string.Format("{0}@{1}#{2}", hostName, pid, Interlocked.Increment(ref instanceSequence));
this._requestTimeout = TimeSpan.FromSeconds(3);
this.longPollingIoTimeout_ = TimeSpan.FromSeconds(30);
this.client_type_ = rmq::ClientType.Unspecified;
@@ -110,11 +112,6 @@ namespace Org.Apache.Rocketmq
set { tracingEnabled_ = value; }
}
- public void setInstanceName(string instanceName)
- {
- this.instanceName_ = instanceName;
- }
-
private string _region = "cn-hangzhou";
private string _serviceName = "ONS";
@@ -132,8 +129,6 @@ namespace Org.Apache.Rocketmq
private bool tracingEnabled_;
- private string instanceName_ = "default";
-
private rmq::ClientType client_type_;
public rmq::ClientType ClientType
{