lizhimins commented on code in PR #1153: URL: https://github.com/apache/rocketmq-clients/pull/1153#discussion_r2650092094
########## java/client/src/main/java/org/apache/rocketmq/client/java/example/ProducerPriorityMessageExample.java: ########## @@ -0,0 +1,64 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.rocketmq.client.java.example; + +import java.nio.charset.StandardCharsets; +import org.apache.rocketmq.client.apis.ClientException; +import org.apache.rocketmq.client.apis.ClientServiceProvider; +import org.apache.rocketmq.client.apis.message.Message; +import org.apache.rocketmq.client.apis.producer.Producer; +import org.apache.rocketmq.client.apis.producer.SendReceipt; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class ProducerPriorityMessageExample { + private static final Logger log = LoggerFactory.getLogger(ProducerPriorityMessageExample.class); + + private ProducerPriorityMessageExample() { + } + + public static void main(String[] args) throws ClientException { + final ClientServiceProvider provider = ClientServiceProvider.loadService(); + + String topic = "yourPriorityTopic"; + final Producer producer = ProducerSingleton.getInstance(topic); + // Define your message body. + byte[] body = "This is a delay message for Apache RocketMQ".getBytes(StandardCharsets.UTF_8); + String tag = "yourMessageTagA"; + final Message message = provider.newMessageBuilder() + // Set topic for the current message. + .setTopic(topic) + // Message secondary classifier of message besides topic. + .setTag(tag) + // Key(s) of the message, another way to mark message besides message id. + .setKeys("yourMessageKey") + // Set priority of message. + .setPriority(1) Review Comment: Add the new feature to the capability set in readme.md -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
