wu-sheng commented on code in PR #598: URL: https://github.com/apache/skywalking-java/pull/598#discussion_r1306310885
########## test/plugin/scenarios/rocketmq-5-grpc-scenario/src/main/java/test/apache/skywalking/apm/testcase/rocketmq/client/java/controller/CaseController.java: ########## @@ -0,0 +1,151 @@ +/* + * 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 test.apache.skywalking.apm.testcase.rocketmq.client.java.controller; + +import lombok.extern.slf4j.Slf4j; +import org.apache.rocketmq.client.apis.ClientConfiguration; +import org.apache.rocketmq.client.apis.ClientServiceProvider; +import org.apache.rocketmq.client.apis.consumer.FilterExpression; +import org.apache.rocketmq.client.apis.consumer.FilterExpressionType; +import org.apache.rocketmq.client.apis.consumer.MessageListener; +import org.apache.rocketmq.client.apis.consumer.ConsumeResult; +import org.apache.rocketmq.client.apis.consumer.PushConsumer; +import org.apache.rocketmq.client.apis.message.Message; +import org.apache.rocketmq.client.apis.message.MessageView; +import org.apache.rocketmq.client.apis.producer.Producer; +import org.apache.rocketmq.client.apis.producer.SendReceipt; +import org.apache.rocketmq.common.MixAll; +import org.apache.rocketmq.tools.command.MQAdminStartup; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.bind.annotation.RestController; + +import java.nio.charset.StandardCharsets; +import java.util.Collections; +import java.util.Date; + +@RestController +@RequestMapping("/case") +@Slf4j +public class CaseController { + + private static final String SUCCESS = "Success"; + + @Value("${endpoints}") + private String endpoints; + + @Value("${nameServer}") + private String nameServer; + + static final String TOPIC = "TopicTest"; + static final String TAG = "TagA"; + static final String GROUP = "group1"; + + @RequestMapping("/rocketmq-5-grpc-scenario") + @ResponseBody + public String testcase() { + try { + ClientServiceProvider provider = ClientServiceProvider.loadService(); + ClientConfiguration clientConfiguration = ClientConfiguration.newBuilder() + .setEndpoints(endpoints) + .enableSsl(false) + .build(); + // start producer + Producer producer = provider.newProducerBuilder() + .setClientConfiguration(clientConfiguration) + .build(); + System.out.printf("Provider Started.%n"); + + // send msg + 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("KeyA") + .setBody("This is a normal message for Apache RocketMQ".getBytes(StandardCharsets.UTF_8)) + .build(); + SendReceipt sendReceipt = producer.send(message); + System.out.printf("%s send msg successfully, message: %s%n", new Date(), sendReceipt); + + // start consumer + Thread thread = new Thread(new Runnable() { Review Comment: Ref can't prove it is correct or wrong. Sometimes, wrong things got missed from last review. -- 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]
