xiongzhu 4 years ago
parent
commit
b3ab5e6021

+ 2 - 0
src/main/java/com/izouma/nineth/config/GeneralProperties.java

@@ -28,4 +28,6 @@ public class GeneralProperties {
     private int     workerId;
     private String  updateQuotaGroup;
     private String  updateQuotaTopic;
+    private String  broadcastEventGroup;
+    private String  broadcastEventTopic;
 }

+ 27 - 0
src/main/java/com/izouma/nineth/listener/BroadcastEventListener.java

@@ -0,0 +1,27 @@
+package com.izouma.nineth.listener;
+
+import com.alibaba.fastjson.JSONObject;
+import com.alibaba.fastjson.serializer.SerializerFeature;
+import lombok.AllArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.rocketmq.spring.annotation.ConsumeMode;
+import org.apache.rocketmq.spring.annotation.MessageModel;
+import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
+import org.apache.rocketmq.spring.core.RocketMQListener;
+import org.springframework.stereotype.Service;
+
+@Service
+@Slf4j
+@AllArgsConstructor
+@RocketMQMessageListener(
+        messageModel = MessageModel.BROADCASTING,
+        consumerGroup = "${general.broadcast-event-group}",
+        topic = "${general.broadcast-event-topic}",
+        consumeMode = ConsumeMode.ORDERLY)
+public class BroadcastEventListener implements RocketMQListener<JSONObject> {
+
+    @Override
+    public void onMessage(JSONObject message) {
+        log.info("接收到广播事件 {}", JSONObject.toJSONString(message, SerializerFeature.PrettyFormat));
+    }
+}

+ 10 - 0
src/main/resources/application.yaml

@@ -155,6 +155,8 @@ general:
   update-activity-stock-topic: update-activity-stock-topic-dev
   update-quota-group: update-quota-group-dev
   update-quota-topic: update-quota-topic-dev
+  broadcast-event-group: broadcast-event-group-dev
+  broadcast-event-topic: broadcast-event-topic-dev
 mychain:
   rest:
     bizid: a00e36c5
@@ -233,6 +235,8 @@ general:
   update-activity-stock-topic: update-activity-stock-topic-test
   update-quota-group: update-quota-group-test
   update-quota-topic: update-quota-topic-test
+  broadcast-event-group: broadcast-event-group-test
+  broadcast-event-topic: broadcast-event-topic-test
 ---
 
 spring:
@@ -262,6 +266,8 @@ general:
   update-activity-stock-topic: update-activity-stock-topic-test1
   update-quota-group: update-quota-group-test1
   update-quota-topic: update-quota-topic-test1
+  broadcast-event-group: broadcast-event-group-test1
+  broadcast-event-topic: broadcast-event-topic-test1
 wx:
   pay:
     notify-url: https://test1.raex.vip/notify/order/weixin
@@ -316,6 +322,8 @@ general:
   update-activity-stock-topic: update-activity-stock-topic
   update-quota-group: update-quota-group
   update-quota-topic: update-quota-topic
+  broadcast-event-group: broadcast-event-group
+  broadcast-event-topic: broadcast-event-topic
 wx:
   pay:
     notify-url: https://www.raex.vip/notify/order/weixin
@@ -406,6 +414,8 @@ general:
   update-activity-stock-topic: update-activity-stock-topic-test
   update-quota-group: update-quota-group-test
   update-quota-topic: update-quota-topic-test
+  broadcast-event-group: broadcast-event-group-test
+  broadcast-event-topic: broadcast-event-topic-test
 rocketmq:
   name-server: 172.29.50.102:9876
   producer: