Release Notes
Announcements
dotnet add package NewLife.RocketMQ --version 2.0.2022.325-beta0806
//Producer.var mq = new Producer{Topic = "TopicTest1", //For a non-general cluster, you need to concatenate the complete topic, such as MQ_INSTxxx_aaa%TopicTest.NameServerAddress = "127.0.0.1:9876",// Enter it on the Tencent Cloud page.Log = XTrace.Log,AclOptions = new AclOptions{AccessKey = "AccessKey of the page",SecretKey = "SecretKey of the page",},};mq.Start();for (var i = 0; i < 10; i++){var str = "Message production test" + i;var sr = mq.Publish(str, "TagA");}
Parameter | Description |
Topic | Topic name. You can copy the name from the Topic Management page in the console. 4.x virtual/exclusive cluster: Concatenate the namespace name in the format of full namespace name%topic name, such as MQ_INSTxxx_aaa%TopicTest.4.x general cluster/5.x cluster: The namespace name does not need to be concatenated. Enter the topic name. |
NameServerAddress | Cluster access address. You can obtain the access address from the Access Information module on the Cluster Basic Information page in the console. |
SecretKey | Role name. You can copy the role name from the SecretKey column on the Cluster Permissions page in the console. |
AccessKey | Role token. You can copy the token from the AccessKey column on the Cluster Permissions page in the console. |
TAGS | Tags associated with the message. |
//Consumer.var consumer = new Consumer{Topic = "TopicTest1", //For a non-general cluster, you need to concatenate a complete topic, such as MQ_INSTxxx_aaa%TopicTest.Group = "test", // For a non-general cluster, you need to concatenate a complete group, such as MQ_INSTxxx_aaa%GroupTest.NameServerAddress = "127.0.0.1:9876",FromLastOffset = true,SkipOverStoredMsgCount = 0,BatchSize = 20,Log = XTrace.Log,AclOptions = new AclOptions{AccessKey = "AccessKey of the page",SecretKey = "SecretKey of the page",},};consumer.OnConsume = (q, ms) =>{XTrace.WriteLine("[{0}@{1}] received message [{2}]", q.BrokerName, q.QueueId, ms.Length);foreach (var item in ms.ToList()){XTrace.WriteLine($"message {item.Keys}, sending time {item.BornTimestamp.ToDateTime()}, content {item.Body.ToStr()}");}return true;};consumer.Start();
Parameter | Description |
Topic | Topic name. You can copy the name from the Topic Management page in the console. 4.x virtual/exclusive cluster: Concatenate the namespace name in the format of full namespace name%topic name, such as MQ_INSTxxx_aaa%TopicTest.4.x general cluster/5.x cluster: The namespace name does not need to be concatenated. Enter the topic name. |
Group | Group name. You can copy the name from the Group Management page in the console. 4.x virtual cluster/exclusive cluster: Concatenate the namespace name in the format of full namespace name%group name, such as MQ_INSTxxx_aaa%GroupTest.4.x general cluster/5.x cluster: The namespace name does not need to be concatenated. Enter the group name. |
NameServerAddress | Cluster access address. You can obtain the access address from the Access Information module on the Cluster Basic Information page in the console. |
SecretKey | Role name. You can copy the role name from the SecretKey column on the Cluster Permissions page in the console. |
AccessKey | Role token. You can copy the token from the AccessKey column on the Cluster Permissions page in the console. |
Was this page helpful?
You can also Contact sales or Submit a Ticket for help.
Help us improve! Rate your documentation experience in 5 mins.
Feedback