You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@eventmesh.apache.org by GitBox <gi...@apache.org> on 2021/11/29 12:33:38 UTC

[GitHub] [incubator-eventmesh] ruanwenjun commented on a change in pull request #531: create topic command

ruanwenjun commented on a change in pull request #531:
URL: https://github.com/apache/incubator-eventmesh/pull/531#discussion_r758317598



##########
File path: eventmesh-connector-plugin/eventmesh-connector-rocketmq/src/main/resources/rocketmq-client.properties
##########
@@ -16,3 +16,6 @@
 #
 #######################rocketmq-client##################
 eventMesh.server.rocketmq.namesrvAddr=127.0.0.1:9876;127.0.0.1:9876
+eventMesh.server.rocketmq.cluster=********

Review comment:
       Can we add a default value here? Maybe it can run success in most times.

##########
File path: eventmesh-connector-plugin/eventmesh-connector-rocketmq/src/test/java/org/apache/eventmesh/producer/DefaultProducerImplTest.java
##########
@@ -0,0 +1,63 @@
+/*
+ * 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.eventmesh.producer;
+
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+import org.apache.eventmesh.api.producer.MeshMQProducer;
+import org.apache.eventmesh.connector.rocketmq.producer.RocketMQProducerImpl;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+import io.openmessaging.api.exception.OMSRuntimeException;
+
+public class DefaultProducerImplTest {
+
+    @Before
+    public void before() {}
+
+
+    @After
+    public void after() {
+        //TBD:Remove topic
+    }
+
+    @Test
+    public void testCreate_EmptyTopic() {
+        MeshMQProducer meshPub = new RocketMQProducerImpl();
+        try {
+            meshPub.createTopic("");
+        } catch (OMSRuntimeException e) {           
+            assertThat(e.getMessage()).isEqualTo("RocketMQ can not create topic .");

Review comment:
       ```suggestion
   assertThat(e.getMessage()).isEqualTo("RocketMQ can not create topic.");
   ```

##########
File path: eventmesh-connector-plugin/eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/producer/RocketMQProducerImpl.java
##########
@@ -149,4 +158,16 @@ public void updateCredential(Properties credentialProperties) {
     public <T> MessageBuilder<T> messageBuilder() {
         return null;
     }
+
+    @Override
+    public void createTopic(String topicName) throws OMSRuntimeException {
+        CreateTopicCommand createTopicCommand = new CreateTopicCommand();
+        createTopicCommand.setTopicName(topicName);
+        try {
+            createTopicCommand.execute();
+        } catch (Exception e) {
+            throw new OMSRuntimeException(-1, 
+                String.format("RocketMQ can not create topic %s.", topicName), e);

Review comment:
       It might be better don't add an error code casually here.

##########
File path: eventmesh-connector-plugin/eventmesh-connector-rocketmq/src/main/java/org/apache/eventmesh/connector/rocketmq/producer/RocketMQProducerImpl.java
##########
@@ -149,4 +158,16 @@ public void updateCredential(Properties credentialProperties) {
     public <T> MessageBuilder<T> messageBuilder() {
         return null;
     }
+
+    @Override
+    public void createTopic(String topicName) throws OMSRuntimeException {
+        CreateTopicCommand createTopicCommand = new CreateTopicCommand();
+        createTopicCommand.setTopicName(topicName);
+        try {
+            createTopicCommand.execute();
+        } catch (Exception e) {
+            throw new OMSRuntimeException(-1, 
+                String.format("RocketMQ can not create topic %s.", topicName), e);

Review comment:
       ```suggestion
   throw new OMSRuntimeException(
                   String.format("RocketMQ can not create topic %s.", topicName), e);
   ```




-- 
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: dev-unsubscribe@eventmesh.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@eventmesh.apache.org
For additional commands, e-mail: dev-help@eventmesh.apache.org