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

lizhanhui 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 42d42d2  Update protocol files (#204)
42d42d2 is described below

commit 42d42d29e2a3cb97831874127cd00472b1b539a0
Author: Zhanhui Li <[email protected]>
AuthorDate: Tue Aug 30 15:55:05 2022 +0800

    Update protocol files (#204)
    
    * Use latest protobuf protocol files
    
    * Update .gitignore file
---
 .gitignore                                         |   5 +-
 csharp/examples/Program.cs                         |  81 +++---
 csharp/rocketmq-client-csharp/AccessPoint.cs       |  20 ++
 .../Protos/apache/rocketmq/v2/definition.proto     | 285 ++++++++++++++-------
 .../Protos/apache/rocketmq/v2/service.proto        |  97 +------
 5 files changed, 251 insertions(+), 237 deletions(-)

diff --git a/.gitignore b/.gitignore
index 4141719..1351081 100644
--- a/.gitignore
+++ b/.gitignore
@@ -27,8 +27,11 @@ dependency-reduced-pom.xml
 
 # C# 
 obj/
+csharp/examples/bin/
+csharp/rocketmq-client-csharp/bin/
+csharp/tests/bin/
 
 # Rust
 rust/target
 rust/Cargo.lock
-rust/src/pb/*.rs
\ No newline at end of file
+rust/src/pb/*.rs
diff --git a/csharp/examples/Program.cs b/csharp/examples/Program.cs
index 4a5ef3f..ad7e979 100644
--- a/csharp/examples/Program.cs
+++ b/csharp/examples/Program.cs
@@ -15,67 +15,50 @@
  * limitations under the License.
  */
 using System;
+using System.Collections.Generic;
 using System.Threading.Tasks;
 using System.Threading;
+using Org.Apache.Rocketmq;
 
 namespace examples
 {
-
-    class Foo
-    {
-        public int bar = 1;
-    }
     class Program
     {
-
-        static void RT(Action action, int seconds, CancellationToken token)
-        {
-            if (null == action)
-            {
-                return;
-            }
-
-            Task.Run(async () =>
-            {
-                while (!token.IsCancellationRequested)
-                {
-                    action();
-                    await Task.Delay(TimeSpan.FromSeconds(seconds), token);
-                }
-            });
-        }
-
-        static void Main(string[] args)
+        static async Task Main(string[] args)
         {
             Console.WriteLine("Hello World!");
+            string accessUrl = 
"rmq-cn-7mz2uk4nn0p.cn-hangzhou.rmq.aliyuncs.com:8080";
+            string accessKey = "949WI12QS2OJv39o";
+            string accessSecret = "870Rz9tptlt9oNEJ";
+            var credentialsProvider = new StaticCredentialsProvider(accessKey, 
accessSecret);
+            var accessPoint = new AccessPoint(accessUrl);
+            var producer = new Producer(accessPoint, "");
+            producer.CredentialsProvider = credentialsProvider;
+            await producer.Start();
 
-            string accessKey = "key";
-            string accessSecret = "secret";
-            var credentials = new 
Org.Apache.Rocketmq.StaticCredentialsProvider(accessKey, 
accessSecret).getCredentials();
-            bool expired = credentials.expired();
-
-            int workerThreads;
-            int completionPortThreads;
-            ThreadPool.GetMaxThreads(out workerThreads, out 
completionPortThreads);
-            Console.WriteLine($"Max: workerThread={workerThreads}, 
completionPortThreads={completionPortThreads}");
-            ThreadPool.GetMinThreads(out workerThreads, out 
completionPortThreads);
-            Console.WriteLine($"Min: workerThread={workerThreads}, 
completionPortThreads={completionPortThreads}");
-
-            ThreadPool.QueueUserWorkItem((Object stateInfo) =>
+            var topic = "sdk_standard";
+            
+            byte[] body = new byte[1024];
+            Array.Fill(body, (byte)'x');
+            // Associate the message with one or multiple keys
+            var keys = new List<string>
             {
-                Console.WriteLine("From ThreadPool");
-                if (stateInfo is Foo)
-                {
-                    Console.WriteLine("Foo: bar=" + (stateInfo as Foo).bar);
-                }
-            }, new Foo());
-
-            var cts = new CancellationTokenSource();
-            RT(() =>
+                "k1",
+                "k2"
+            };
+            
+            var msg = new Message(topic, body)
             {
-                Console.WriteLine("Hello Again" + Thread.CurrentThread.Name);
-            }, 1, cts.Token);
-            cts.CancelAfter(3000);
+                // Tag the massage. A message has at most one tag.
+                Tag = "Tag-0",
+                Keys = keys
+            };
+            
+            msg.Keys = keys;
+
+            var sendReceipt = await producer.Send(msg);
+            Console.WriteLine(sendReceipt.MessageId);
+            
             Console.ReadKey();
         }
     }
diff --git a/csharp/rocketmq-client-csharp/AccessPoint.cs 
b/csharp/rocketmq-client-csharp/AccessPoint.cs
index cf4e1f4..f4ba47c 100644
--- a/csharp/rocketmq-client-csharp/AccessPoint.cs
+++ b/csharp/rocketmq-client-csharp/AccessPoint.cs
@@ -14,10 +14,30 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
+
+using System;
+
 namespace Org.Apache.Rocketmq
 {
     public class AccessPoint
     {
+        public AccessPoint()
+        {
+            
+        }
+
+        public AccessPoint(string accessUrl)
+        {
+            string[] segments = accessUrl.Split(":");
+            if (segments.Length != 2)
+            {
+                throw new ArgumentException("Access url should be of format 
host:port");
+            }
+
+            _host = segments[0];
+            _port = Int32.Parse(segments[1]);
+        }
+        
         private string _host;
 
         public string Host
diff --git 
a/csharp/rocketmq-client-csharp/Protos/apache/rocketmq/v2/definition.proto 
b/csharp/rocketmq-client-csharp/Protos/apache/rocketmq/v2/definition.proto
index 684cade..f0a637d 100644
--- a/csharp/rocketmq-client-csharp/Protos/apache/rocketmq/v2/definition.proto
+++ b/csharp/rocketmq-client-csharp/Protos/apache/rocketmq/v2/definition.proto
@@ -175,10 +175,6 @@ enum DigestType {
 // 1) Standard messages should be negatively acknowledged instantly, causing
 // immediate re-delivery; 2) FIFO messages require special RPC, to re-fetch
 // previously acquired messages batch;
-//
-// Message consumption model also affects how invalid digest are handled. When
-// messages are consumed in broadcasting way,
-// TODO: define semantics of invalid-digest-when-broadcasting.
 message Digest {
   DigestType type = 1;
   string checksum = 2;
@@ -288,109 +284,103 @@ message Message {
   bytes body = 4;
 }
 
-message Assignment { MessageQueue message_queue = 1; }
+message Assignment {
+  MessageQueue message_queue = 1;
+}
 
 enum Code {
-  // Success.
-  OK = 0;
+  CODE_UNSPECIFIED = 0;
+
+  // Generic code for success.
+  OK = 20000;
+
+  // Generic code for multiple return results.
+  MULTIPLE_RESULTS = 30000;
+
+  // Generic code for bad request, indicating that required fields or headers 
are missing.
+  BAD_REQUEST = 40000;
   // Format of access point is illegal.
-  ILLEGAL_ACCESS_POINT = 1;
+  ILLEGAL_ACCESS_POINT = 40001;
   // Format of topic is illegal.
-  ILLEGAL_TOPIC = 2;
+  ILLEGAL_TOPIC = 40002;
   // Format of consumer group is illegal.
-  ILLEGAL_CONSUMER_GROUP = 3;
+  ILLEGAL_CONSUMER_GROUP = 40003;
   // Format of message tag is illegal.
-  ILLEGAL_MESSAGE_TAG = 4;
+  ILLEGAL_MESSAGE_TAG = 40004;
   // Format of message key is illegal.
-  ILLEGAL_MESSAGE_KEY = 5;
-  // Size of message keys exceeds the threshold.
-  MESSAGE_KEYS_TOO_LARGE = 6;
+  ILLEGAL_MESSAGE_KEY = 40005;
   // Format of message group is illegal.
-  ILLEGAL_MESSAGE_GROUP = 7;
+  ILLEGAL_MESSAGE_GROUP = 40006;
   // Format of message property key is illegal.
-  ILLEGAL_MESSAGE_PROPERTY_KEY = 8;
-  // Message properties total size exceeds the threshold.
-  MESSAGE_PROPERTIES_TOO_LARGE = 9;
-  // Message body size exceeds the threshold.
-  MESSAGE_BODY_TOO_LARGE = 10;
-
-  // User does not have the permission to operate.
-  // See https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/403
-  FORBIDDEN = 403;
-
-  // Code indicates that the client request has not been completed
-  // because it lacks valid authentication credentials for the
-  // requested resource.
-  // See https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/401
-  UNAUTHORIZED = 401;
-
-  // Topic resource does not exist.
-  TOPIC_NOT_FOUND = 13;
-
-  // Consumer group resource does not exist.
-  CONSUMER_GROUP_NOT_FOUND = 14;
-
-  // Not allowed to verify message. Chances are that you are verifying
-  // a FIFO message, as is violating FIFO semantics.
-  VERIFY_MESSAGE_FORBIDDEN = 15;
-
-  // Failed to consume message.
-  FAILED_TO_CONSUME_MESSAGE = 16;
-
-  // Message is corrupted.
-  MESSAGE_CORRUPTED = 17;
-
-  // Too many requests are made in short period of duration.
-  // Requests are throttled.
-  TOO_MANY_REQUESTS = 18;
-
-  // Expired receipt-handle is used when trying to acknowledge or change
-  // invisible duration of a message
-  RECEIPT_HANDLE_EXPIRED = 19;
-
-  // Message property is not match the message type.
-  MESSAGE_PROPERTY_DOES_NOT_MATCH_MESSAGE_TYPE = 20;
-
-  // Format of message id is illegal.
-  ILLEGAL_MESSAGE_ID = 21;
-
+  ILLEGAL_MESSAGE_PROPERTY_KEY = 40007;
   // Transaction id is invalid.
-  INVALID_TRANSACTION_ID = 22;
-
+  INVALID_TRANSACTION_ID = 40008;
+  // Format of message id is illegal.
+  ILLEGAL_MESSAGE_ID = 40009;
   // Format of filter expression is illegal.
-  ILLEGAL_FILTER_EXPRESSION = 23;
-
+  ILLEGAL_FILTER_EXPRESSION = 40010;
+  // The invisible time of request is invalid.
+  ILLEGAL_INVISIBLE_TIME = 40011;
+  // The delivery timestamp of message is invalid.
+  ILLEGAL_DELIVERY_TIME = 40012;
   // Receipt handle of message is invalid.
-  INVALID_RECEIPT_HANDLE = 24;
-
-  // Message persistence timeout.
-  MASTER_PERSISTENCE_TIMEOUT = 25;
+  INVALID_RECEIPT_HANDLE = 40013;
+  // Message property conflicts with its type.
+  MESSAGE_PROPERTY_CONFLICT_WITH_TYPE = 40014;
+  // Client type could not be recognized.
+  UNRECOGNIZED_CLIENT_TYPE = 40015;
+  // Message is corrupted.
+  MESSAGE_CORRUPTED = 40016;
+  // Request is rejected due to missing of x-mq-client-id header.
+  CLIENT_ID_REQUIRED = 40017;
+  // Polling time is illegal.
+  ILLEGAL_POLLING_TIME = 40018;
 
-  // Slave persistence timeout.
-  SLAVE_PERSISTENCE_TIMEOUT = 26;
+  // Generic code indicates that the client request lacks valid authentication
+  // credentials for the requested resource.
+  UNAUTHORIZED = 40100;
 
-  // The HA-mechanism is not working now.
-  HA_NOT_AVAILABLE = 27;
+  // Generic code indicates that the account is suspended due to overdue of 
payment.
+  PAYMENT_REQUIRED = 40200;
 
-  // Operation is not allowed in current version.
-  VERSION_UNSUPPORTED = 28;
+  // Generic code for the case that user does not have the permission to 
operate.
+  FORBIDDEN = 40300;
 
+  // Generic code for resource not found.
+  NOT_FOUND = 40400;
   // Message not found from server.
-  MESSAGE_NOT_FOUND = 29;
+  MESSAGE_NOT_FOUND = 40401;
+  // Topic resource does not exist.
+  TOPIC_NOT_FOUND = 40402;
+  // Consumer group resource does not exist.
+  CONSUMER_GROUP_NOT_FOUND = 40403;
 
-  // Message offset is illegal.
-  ILLEGAL_MESSAGE_OFFSET = 30;
+  // Generic code representing client side timeout when connecting to, reading 
data from, or write data to server.
+  REQUEST_TIMEOUT = 40800;
 
-  // Illegal message is for the sake of backward compatibility. In most case,
-  // more definitive code is better, e.g. `ILLEGAL_MESSAGE_TAG`.
-  ILLEGAL_MESSAGE = 31;
+  // Generic code represents that the request entity is larger than limits 
defined by server.
+  PAYLOAD_TOO_LARGE = 41300;
+  // Message body size exceeds the threshold.
+  MESSAGE_BODY_TOO_LARGE = 41301;
 
-  // Client type could not be recognized.
-  UNRECOGNIZED_CLIENT_TYPE = 32;
+  // Generic code for use cases where pre-conditions are not met.
+  // For example, if a producer instance is used to publish messages without 
prior start() invocation,
+  // this error code will be raised.
+  PRECONDITION_FAILED = 42800;
 
-  // Return different results for entries in composite request.
-  MULTIPLE_RESULTS = 33;
+  // Generic code indicates that too many requests are made in short period of 
duration.
+  // Requests are throttled.
+  TOO_MANY_REQUESTS = 42900;
+
+  // Generic code for the case that the server is unwilling to process the 
request because its header fields are too large.
+  // The request may be resubmitted after reducing the size of the request 
header fields.
+  REQUEST_HEADER_FIELDS_TOO_LARGE = 43100;
+  // Message properties total size exceeds the threshold.
+  MESSAGE_PROPERTIES_TOO_LARGE = 43101;
 
+  // Generic code indicates that server/client encountered an unexpected
+  // condition that prevented it from fulfilling the request.
+  INTERNAL_ERROR = 50000;
   // Code indicates that the server encountered an unexpected condition
   // that prevented it from fulfilling the request.
   // This error response is a generic "catch-all" response.
@@ -400,17 +390,33 @@ enum Code {
   // to prevent the error from happening again in the future.
   //
   // See https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/500
-  INTERNAL_SERVER_ERROR = 500;
+  INTERNAL_SERVER_ERROR = 50001;
+  // The HA-mechanism is not working now.
+  HA_NOT_AVAILABLE = 50002;
 
-  // Code means that the server or client does not support the functionality
-  // required to fulfill the request.
-  NOT_IMPLEMENTED = 501;
+  // Generic code means that the server or client does not support the
+  // functionality required to fulfill the request.
+  NOT_IMPLEMENTED = 50100;
 
-  // Code indicates that the server, while acting as a gateway or proxy,
-  // did not get a response in time from the upstream server that
-  // it needed in order to complete the request.
+  // Generic code represents that the server, which acts as a gateway or proxy,
+  // does not get an satisfied response in time from its upstream servers.
   // See https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/504
-  GATEWAY_TIMEOUT = 504;
+  PROXY_TIMEOUT = 50400;
+  // Message persistence timeout.
+  MASTER_PERSISTENCE_TIMEOUT = 50401;
+  // Slave persistence timeout.
+  SLAVE_PERSISTENCE_TIMEOUT = 50402;
+
+  // Generic code for unsupported operation.
+  UNSUPPORTED = 50500;
+  // Operation is not allowed in current version.
+  VERSION_UNSUPPORTED = 50501;
+  // Not allowed to verify message. Chances are that you are verifying
+  // a FIFO message, as is violating FIFO semantics.
+  VERIFY_FIFO_MESSAGE_UNSUPPORTED = 50502;
+
+  // Generic code for failed message consumption.
+  FAILED_TO_CONSUME_MESSAGE = 60000;
 }
 
 message Status {
@@ -425,6 +431,13 @@ enum Language {
   DOT_NET = 3;
   GOLANG = 4;
   RUST = 5;
+  PYTHON = 6;
+  PHP = 7;
+  NODE_JS = 8;
+  RUBY = 9;
+  OBJECTIVE_C = 10;
+  DART = 11;
+  KOTLIN = 12;
 }
 
 // User Agent
@@ -440,4 +453,90 @@ message UA {
 
   // Hostname of the node
   string hostname = 4;
+}
+
+message Settings {
+  // Configurations for all clients.
+  optional ClientType client_type = 1;
+
+  optional Endpoints access_point = 2;
+
+  // If publishing of messages encounters throttling or server internal errors,
+  // publishers should implement automatic retries after progressive longer
+  // back-offs for consecutive errors.
+  //
+  // When processing message fails, `backoff_policy` describes an interval
+  // after which the message should be available to consume again.
+  //
+  // For FIFO messages, the interval should be relatively small because
+  // messages of the same message group would not be readily available until
+  // the prior one depletes its lifecycle.
+  optional RetryPolicy backoff_policy = 3;
+
+  // Request timeout for RPCs excluding long-polling.
+  optional google.protobuf.Duration request_timeout = 4;
+
+  oneof pub_sub {
+    Publishing publishing = 5;
+
+    Subscription subscription = 6;
+  }
+
+  // User agent details
+  UA user_agent = 7;
+
+  Metric metric = 8;
+}
+
+message Publishing {
+  // Publishing settings below here is appointed by client, thus it is
+  // unnecessary for server to push at present.
+  //
+  // List of topics to which messages will publish to.
+  repeated Resource topics = 1;
+
+  // If the message body size exceeds `max_body_size`, broker servers would
+  // reject the request. As a result, it is advisable that Producer performs
+  // client-side check validation.
+  int32 max_body_size = 2;
+
+  // When `validate_message_type` flag set `false`, no need to validate 
message's type
+  // with messageQueue's `accept_message_types` before publishing.
+  bool validate_message_type = 3;
+}
+
+message Subscription {
+  // Subscription settings below here is appointed by client, thus it is
+  // unnecessary for server to push at present.
+  //
+  // Consumer group.
+  optional Resource group = 1;
+
+  // Subscription for consumer.
+  repeated SubscriptionEntry subscriptions = 2;
+
+  // Subscription settings below here are from server, it is essential for
+  // server to push.
+  //
+  // When FIFO flag is `true`, messages of the same message group are processed
+  // in first-in-first-out manner.
+  //
+  // Brokers will not deliver further messages of the same group until prior
+  // ones are completely acknowledged.
+  optional bool fifo = 3;
+
+  // Message receive batch size here is essential for push consumer.
+  optional int32 receive_batch_size = 4;
+
+  // Long-polling timeout for `ReceiveMessageRequest`, which is essential for
+  // push consumer.
+  optional google.protobuf.Duration long_polling_timeout = 5;
+}
+
+message Metric {
+  // Indicates that if client should export local metrics to server.
+  bool on = 1;
+
+  // The endpoint that client metrics should be exported to, which is required 
if the switch is on.
+  optional Endpoints endpoints = 2;
 }
\ No newline at end of file
diff --git 
a/csharp/rocketmq-client-csharp/Protos/apache/rocketmq/v2/service.proto 
b/csharp/rocketmq-client-csharp/Protos/apache/rocketmq/v2/service.proto
index c7ce2e9..8e880e2 100644
--- a/csharp/rocketmq-client-csharp/Protos/apache/rocketmq/v2/service.proto
+++ b/csharp/rocketmq-client-csharp/Protos/apache/rocketmq/v2/service.proto
@@ -175,8 +175,7 @@ message ThreadStackTrace {
 
 message VerifyMessageCommand {
   string nonce = 1;
-  MessageQueue message_queue = 2;
-  Message message = 3;
+  Message message = 2;
 }
 
 message VerifyMessageResult {
@@ -184,98 +183,8 @@ message VerifyMessageResult {
 }
 
 message RecoverOrphanedTransactionCommand {
-  MessageQueue message_queue = 1;
-  Message orphaned_transactional_message = 2;
-  string transaction_id = 3;
-}
-
-message Publishing {
-  // Publishing settings below here is appointed by client, thus it is
-  // unnecessary for server to push at present.
-  //
-  // List of topics to which messages will publish to.
-  repeated Resource topics = 1;
-
-  // Publishing settings below here are from server, it is essential for
-  // server to push.
-  //
-  // Body of message will be deflated if its size in bytes exceeds the
-  // threshold.
-  int32 compress_body_threshold = 2;
-
-  // If the message body size exceeds `max_body_size`, broker servers would
-  // reject the request. As a result, it is advisable that Producer performs
-  // client-side check validation.
-  int32 max_body_size = 3;
-}
-
-message Subscription {
-  // Subscription settings below here is appointed by client, thus it is
-  // unnecessary for server to push at present.
-  //
-  // Consumer group.
-  optional Resource group = 1;
-
-  // Subscription for consumer.
-  repeated SubscriptionEntry subscriptions = 2;
-
-  // Subscription settings below here are from server, it is essential for
-  // server to push.
-  //
-  // When FIFO flag is `true`, messages of the same message group are processed
-  // in first-in-first-out manner.
-  //
-  // Brokers will not deliver further messages of the same group utill prior
-  // ones are completely acknowledged.
-  optional bool fifo = 3;
-
-  // Message receive batch size here is essential for push consumer.
-  optional int32 receive_batch_size = 4;
-
-  // Long-polling timeout for `ReceiveMessageRequest`, which is essential for
-  // push consumer.
-  optional google.protobuf.Duration long_polling_timeout = 5;
-}
-
-message Metric {
-  // Indicates that if client should export local metrics to server.
-  bool on = 1;
-  
-  // The endpoint that client metrics should be exported to, which is required 
if the switch is on.
-  optional Endpoints endpoints = 2;
-}
-
-message Settings {
-  // Configurations for all clients.
-  optional ClientType client_type = 1;
-
-  optional Endpoints access_point = 2;
-
-  // If publishing of messages encounters throttling or server internal errors,
-  // publishers should implement automatic retries after progressive longer
-  // back-offs for consecutive errors.
-  //
-  // When processing message fails, `backoff_policy` describes an interval
-  // after which the message should be available to consume again.
-  //
-  // For FIFO messages, the interval should be relatively small because
-  // messages of the same message group would not be readily available utill
-  // the prior one depletes its lifecycle.
-  optional RetryPolicy backoff_policy = 3;
-
-  // Request timeout for RPCs excluding long-polling.
-  optional google.protobuf.Duration request_timeout = 4;
-
-  oneof pub_sub {
-    Publishing publishing = 5;
-
-    Subscription subscription = 6;
-  }
-
-  // User agent details
-  UA user_agent = 7;
-
-  Metric metric = 8;
+  Message message = 1;
+  string transaction_id = 2;
 }
 
 message TelemetryCommand {

Reply via email to