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 1cc2e59c9b9434042f839f64276ae94e90512079 Author: Aaron Ai <[email protected]> AuthorDate: Tue Feb 7 17:41:26 2023 +0800 Format log output --- csharp/examples/ProducerNormalMessageExample.cs | 18 ++++++++++-------- csharp/rocketmq-client-csharp/Client.cs | 2 ++ csharp/rocketmq-client-csharp/MessageQueue.cs | 7 +++++-- csharp/rocketmq-client-csharp/Resource.cs | 6 ++++++ csharp/rocketmq-client-csharp/TopicRouteData.cs | 4 +++- 5 files changed, 26 insertions(+), 11 deletions(-) diff --git a/csharp/examples/ProducerNormalMessageExample.cs b/csharp/examples/ProducerNormalMessageExample.cs index 7aade855..c22bc695 100644 --- a/csharp/examples/ProducerNormalMessageExample.cs +++ b/csharp/examples/ProducerNormalMessageExample.cs @@ -29,25 +29,27 @@ namespace examples internal static async Task QuickStart() { - string accessKey = "5jFk0wK7OU6Uq395"; - string secretKey = "V1u8z19URHs4o6RQ"; + const string accessKey = "5jFk0wK7OU6Uq395"; + const string secretKey = "V1u8z19URHs4o6RQ"; // Credential provider is optional for client configuration. var credentialsProvider = new StaticCredentialsProvider(accessKey, secretKey); - string endpoints = "rmq-cn-7mz30qjc71a.cn-hangzhou.rmq.aliyuncs.com:8080"; - var clientConfig = new ClientConfig(endpoints); - clientConfig.CredentialsProvider = credentialsProvider; + const string endpoints = "rmq-cn-7mz30qjc71a.cn-hangzhou.rmq.aliyuncs.com:8080"; + var clientConfig = new ClientConfig(endpoints) + { + CredentialsProvider = credentialsProvider + }; // In most case, you don't need to create too many producers, single pattern is recommended. var producer = new Producer(clientConfig); - string topic = "lingchu_normal_topic"; + const string topic = "lingchu_normal_topic"; producer.SetTopics(topic); // Set the topic name(s), which is optional but recommended. It makes producer could prefetch // the topic route before message publishing. await producer.Start(); // Define your message body. - byte[] bytes = Encoding.UTF8.GetBytes("foobar"); - string tag = "yourMessageTagA"; + var bytes = Encoding.UTF8.GetBytes("foobar"); + const string tag = "yourMessageTagA"; // You could set multiple keys for the single message. var keys = new List<string> { diff --git a/csharp/rocketmq-client-csharp/Client.cs b/csharp/rocketmq-client-csharp/Client.cs index a63dc038..c4392e2d 100644 --- a/csharp/rocketmq-client-csharp/Client.cs +++ b/csharp/rocketmq-client-csharp/Client.cs @@ -213,6 +213,8 @@ namespace Org.Apache.Rocketmq { var topicRouteData = await FetchTopicRoute0(topic); await OnTopicRouteDataFetched(topic, topicRouteData); + Logger.Info( + $"Fetch topic route successfully, clientId={ClientId}, topic={topic}, topicRouteData={topicRouteData}"); return topicRouteData; } diff --git a/csharp/rocketmq-client-csharp/MessageQueue.cs b/csharp/rocketmq-client-csharp/MessageQueue.cs index b7a6f922..385e392c 100644 --- a/csharp/rocketmq-client-csharp/MessageQueue.cs +++ b/csharp/rocketmq-client-csharp/MessageQueue.cs @@ -35,7 +35,10 @@ namespace Org.Apache.Rocketmq { get { return TopicResource.Name; } } - - + + public override string ToString() + { + return $"{Broker.Name}.{TopicResource}.{QueueId}"; + } } } \ No newline at end of file diff --git a/csharp/rocketmq-client-csharp/Resource.cs b/csharp/rocketmq-client-csharp/Resource.cs index aeca3e4e..5af67d1e 100644 --- a/csharp/rocketmq-client-csharp/Resource.cs +++ b/csharp/rocketmq-client-csharp/Resource.cs @@ -1,3 +1,4 @@ +using System; using rmq = Apache.Rocketmq.V2; namespace Org.Apache.Rocketmq @@ -21,5 +22,10 @@ namespace Org.Apache.Rocketmq Name = Name }; } + + public override string ToString() + { + return String.IsNullOrEmpty(Namespace) ? Name : $"{Namespace}.{Name}"; + } } } \ No newline at end of file diff --git a/csharp/rocketmq-client-csharp/TopicRouteData.cs b/csharp/rocketmq-client-csharp/TopicRouteData.cs index 3c5689a4..05418eaa 100644 --- a/csharp/rocketmq-client-csharp/TopicRouteData.cs +++ b/csharp/rocketmq-client-csharp/TopicRouteData.cs @@ -17,6 +17,7 @@ using System; using System.Collections.Generic; +using System.Linq; using rmq = Apache.Rocketmq.V2; namespace Org.Apache.Rocketmq @@ -59,7 +60,8 @@ namespace Org.Apache.Rocketmq public override string ToString() { - return $"{nameof(MessageQueues)}: {MessageQueues}"; + var mqs = MessageQueues.Select(mq => mq.ToString()).ToList(); + return $"[{string.Join(",", mqs)}]"; } } } \ No newline at end of file
