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/03/08 05:58:53 UTC

[rocketmq-clients] branch master updated (738133d3 -> e7710060)

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

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


    from 738133d3 Add nuget badge
     new 885efc9a Polish code
     new e7710060 Log ClientVersion and .NET version

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 csharp/examples/QuickStart.cs                          |  3 ++-
 csharp/rocketmq-client-csharp/Client.cs                | 18 +++++++++++-------
 csharp/rocketmq-client-csharp/ClientMeterManager.cs    |  4 +---
 csharp/rocketmq-client-csharp/PublishingMessage.cs     |  3 +++
 .../rocketmq-client-csharp.csproj                      |  4 +++-
 5 files changed, 20 insertions(+), 12 deletions(-)


[rocketmq-clients] 02/02: Log ClientVersion and .NET version

Posted by aa...@apache.org.
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 e77100606069b10a6b340e1390829cdf05de5b71
Author: Aaron Ai <ya...@gmail.com>
AuthorDate: Wed Mar 8 13:46:30 2023 +0800

    Log ClientVersion and .NET version
---
 csharp/rocketmq-client-csharp/Client.cs                | 18 +++++++++++-------
 csharp/rocketmq-client-csharp/PublishingMessage.cs     |  3 +++
 .../rocketmq-client-csharp.csproj                      |  4 +++-
 3 files changed, 17 insertions(+), 8 deletions(-)

diff --git a/csharp/rocketmq-client-csharp/Client.cs b/csharp/rocketmq-client-csharp/Client.cs
index b3a38dc6..c5d03286 100644
--- a/csharp/rocketmq-client-csharp/Client.cs
+++ b/csharp/rocketmq-client-csharp/Client.cs
@@ -43,7 +43,7 @@ namespace Org.Apache.Rocketmq
         private static readonly TimeSpan SettingsSyncSchedulePeriod = TimeSpan.FromMinutes(5);
         private readonly CancellationTokenSource _settingsSyncCts;
 
-        private static readonly TimeSpan StatsScheduleDelay = TimeSpan.FromSeconds(60);
+        private static readonly TimeSpan StatsScheduleDelay = TimeSpan.FromSeconds(1);
         private static readonly TimeSpan StatsSchedulePeriod = TimeSpan.FromSeconds(60);
         private readonly CancellationTokenSource _statsCts;
 
@@ -256,10 +256,12 @@ namespace Org.Apache.Rocketmq
         private void Stats()
         {
             ThreadPool.GetAvailableThreads(out var availableWorker, out var availableIo);
-            Logger.Info($"ThreadCount={ThreadPool.ThreadCount}, " +
-                        $"CompletedWorkItemCount={ThreadPool.CompletedWorkItemCount}, " +
-                        $"PendingWorkItemCount={ThreadPool.PendingWorkItemCount}, AvailableWorkerThreads={availableWorker}, " +
-                        $"AvailableCompletionPortThreads={availableIo}, ClientId={ClientId}");
+            Logger.Info(
+                $"ClientId={ClientId}, ClientVersion={MetadataConstants.Instance.ClientVersion}, " +
+                $".NET Version={Environment.Version}, ThreadCount={ThreadPool.ThreadCount}, " +
+                $"CompletedWorkItemCount={ThreadPool.CompletedWorkItemCount}, " +
+                $"PendingWorkItemCount={ThreadPool.PendingWorkItemCount}, AvailableWorkerThreads={availableWorker}, " +
+                $"AvailableCompletionPortThreads={availableIo}");
         }
 
         private void ScheduleWithFixedDelay(Action action, TimeSpan delay, TimeSpan period, CancellationToken token)
@@ -346,7 +348,8 @@ namespace Org.Apache.Rocketmq
             {
                 var endpoints = GetTotalRouteEndpoints();
                 var request = WrapHeartbeatRequest();
-                Dictionary<Endpoints, Task<RpcInvocation<Proto.HeartbeatRequest, Proto.HeartbeatResponse>>> invocations = new();
+                Dictionary<Endpoints, Task<RpcInvocation<Proto.HeartbeatRequest, Proto.HeartbeatResponse>>>
+                    invocations = new();
 
                 // Collect task into a map.
                 foreach (var item in endpoints)
@@ -407,7 +410,8 @@ namespace Org.Apache.Rocketmq
             var request = WrapNotifyClientTerminationRequest();
             foreach (var item in endpoints)
             {
-                var invocation = await ClientManager.NotifyClientTermination(item, request, ClientConfig.RequestTimeout);
+                var invocation =
+                    await ClientManager.NotifyClientTermination(item, request, ClientConfig.RequestTimeout);
                 try
                 {
                     StatusChecker.Check(invocation.Response.Status, request, invocation.RequestId);
diff --git a/csharp/rocketmq-client-csharp/PublishingMessage.cs b/csharp/rocketmq-client-csharp/PublishingMessage.cs
index ff681fe7..7937d933 100644
--- a/csharp/rocketmq-client-csharp/PublishingMessage.cs
+++ b/csharp/rocketmq-client-csharp/PublishingMessage.cs
@@ -68,8 +68,11 @@ namespace Org.Apache.Rocketmq
 
             // For TRANSACTION message.
             if (!string.IsNullOrEmpty(message.MessageGroup) || message.DeliveryTimestamp.HasValue || !txEnabled)
+            {
                 throw new InternalErrorException(
                     "Transactional message should not set messageGroup or deliveryTimestamp");
+            }
+
             MessageType = MessageType.Transaction;
         }
 
diff --git a/csharp/rocketmq-client-csharp/rocketmq-client-csharp.csproj b/csharp/rocketmq-client-csharp/rocketmq-client-csharp.csproj
index 21febf1e..754cd133 100644
--- a/csharp/rocketmq-client-csharp/rocketmq-client-csharp.csproj
+++ b/csharp/rocketmq-client-csharp/rocketmq-client-csharp.csproj
@@ -2,7 +2,8 @@
 
   <PropertyGroup>
     <PackageId>RocketMQ.Client</PackageId>
-    <Version>0.0.1-SNAPSHOT</Version>
+    <!-- Please keep the same with PackageVersion -->
+    <Version>0.0.9-SNAPSHOT</Version>
 
     <Authors>RocketMQ Authors</Authors>
     <Company>Apache Software Foundation</Company>
@@ -14,6 +15,7 @@
     <Description>.NET Client for Apache RocketMQ</Description>
     <PackageProjectUrl>https://github.com/apache/rocketmq-clients</PackageProjectUrl>
     <RepositoryUrl>https://github.com/apache/rocketmq-clients</RepositoryUrl>
+    <!-- Please keep the same with Version -->
     <PackageVersion>0.0.9-SNAPSHOT</PackageVersion>
     <PackageIcon>logo.png</PackageIcon>
   </PropertyGroup>


[rocketmq-clients] 01/02: Polish code

Posted by aa...@apache.org.
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 885efc9ad86923b1f27dd74521af90416f1cce19
Author: Aaron Ai <ya...@gmail.com>
AuthorDate: Wed Mar 8 11:11:00 2023 +0800

    Polish code
---
 csharp/examples/QuickStart.cs                       | 3 ++-
 csharp/rocketmq-client-csharp/ClientMeterManager.cs | 4 +---
 2 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/csharp/examples/QuickStart.cs b/csharp/examples/QuickStart.cs
index d9730cff..2d4a674d 100644
--- a/csharp/examples/QuickStart.cs
+++ b/csharp/examples/QuickStart.cs
@@ -21,9 +21,10 @@ namespace examples
     {
         public static void Main()
         {
-            ProducerNormalMessageExample.QuickStart().Wait();
+            // ProducerNormalMessageExample.QuickStart().Wait();
             // ProducerFifoMessageExample.QuickStart().Wait();
             // ProducerDelayMessageExample.QuickStart().Wait();
+            // ProducerTransactionMessageExample.QuickStart().Wait();
             // SimpleConsumerExample.QuickStart().Wait();
             // ProducerBenchmark.QuickStart().Wait();
         }
diff --git a/csharp/rocketmq-client-csharp/ClientMeterManager.cs b/csharp/rocketmq-client-csharp/ClientMeterManager.cs
index e8eed8d8..a639c984 100644
--- a/csharp/rocketmq-client-csharp/ClientMeterManager.cs
+++ b/csharp/rocketmq-client-csharp/ClientMeterManager.cs
@@ -36,7 +36,6 @@ namespace Org.Apache.Rocketmq
         private readonly Client _client;
         private volatile ClientMeter _clientMeter;
         private readonly HttpClient _httpClient;
-        private readonly object _lock;
         internal readonly Meter Meter;
 
         public ClientMeterManager(Client client)
@@ -45,7 +44,6 @@ namespace Org.Apache.Rocketmq
             var httpDelegatingHandler = new MetricHttpDelegatingHandler(client);
             _httpClient = new HttpClient(httpDelegatingHandler);
             _clientMeter = ClientMeter.DisabledInstance(_client.GetClientId());
-            _lock = new object();
             Meter = new Meter(MeterName, Version);
         }
 
@@ -56,7 +54,7 @@ namespace Org.Apache.Rocketmq
 
         public void Reset(Metric metric)
         {
-            lock (_lock)
+            lock (this)
             {
                 var clientId = _client.GetClientId();
                 if (_clientMeter.Satisfy(metric))