Ver código fonte

新增消息队列功能

liukx@elab 5 anos atrás
pai
commit
0ea7af6896

+ 1 - 1
elab-rocketMQ/src/main/java/com/elab/mq/rocket/utils/MsgConstants.java

@@ -24,6 +24,6 @@ public class MsgConstants {
     /**
      * topic 后缀
      */
-    public static String TOPIC_SUFFIX = "TOPIC";
+    public static String TOPIC_SUFFIX = "topic";
 
 }

+ 1 - 1
springboot-demo/src/main/resources/application.yml

@@ -15,7 +15,7 @@ kafka:
 rocketmq:
     name-server: 192.168.0.24:9876;192.168.0.25:9876
     producer:
-        group: ${spring.profiles.active}-${spring.application.name}
+        group: ${spring.application.name}-${spring.profiles.active}
         sendMessageTimeout: 300000
 spring:
     application:

+ 1 - 5
springboot-demo/src/test/java/com/elab/example/springbootdemo/rocketmq/producerTest.java

@@ -13,7 +13,6 @@ import org.apache.rocketmq.remoting.exception.RemotingException;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Value;
 import org.springframework.boot.test.context.SpringBootTest;
 import org.springframework.test.context.junit4.SpringRunner;
 
@@ -32,8 +31,6 @@ public class producerTest {
     @Autowired
     private DefaultMQProducerExt rocketMQTemplate;
 
-    @Value("${rocketmq.default.topic}")
-    private String topic;
 
     @Test
     public void sendJsonMsg() throws UnsupportedEncodingException, InterruptedException, RemotingException, MQClientException, MQBrokerException {
@@ -42,9 +39,8 @@ public class producerTest {
         jsonObject.put("msg", "my name is lkx");
         Message message = new Message();
         message.setBody(jsonObject.toJSONString().getBytes());
-        message.setTopic(topic);
         message.setTags("");
-        SendResult sendResult = rocketMQTemplate.send(topic, "tag", RandomUtils.randomString(5),
+        SendResult sendResult = rocketMQTemplate.send("elab-rocketMQ", "tag", RandomUtils.randomString(5),
                 jsonObject.toJSONString().getBytes());
         SendStatus sendStatus = sendResult.getSendStatus();
         System.out.println("--->" + sendResult.toString());