loemkie 1 mês atrás
pai
commit
3ddf3b0213

+ 6 - 0
pom.xml

@@ -442,6 +442,12 @@
             <artifactId>mybatis-plus-generator</artifactId>
             <version>3.5.1</version>
         </dependency>
+
+        <dependency>
+            <groupId>org.apache.rocketmq</groupId>
+            <artifactId>rocketmq-client</artifactId>
+            <version>5.3.1</version>
+        </dependency>
     </dependencies>
     <!--<build>
         <finalName>${project.artifactId}</finalName>

+ 57 - 0
src/main/java/com/qmrb/system/mq/PickCarProducer.java

@@ -0,0 +1,57 @@
+package com.qmrb.system.mq;
+
+import org.apache.commons.lang3.time.StopWatch;
+import org.apache.rocketmq.client.exception.MQBrokerException;
+import org.apache.rocketmq.client.exception.MQClientException;
+import org.apache.rocketmq.client.producer.DefaultMQProducer;
+import org.apache.rocketmq.client.producer.SendResult;
+import org.apache.rocketmq.common.message.Message;
+import org.apache.rocketmq.remoting.common.RemotingHelper;
+import org.apache.rocketmq.remoting.exception.RemotingException;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Component;
+
+import javax.annotation.PostConstruct;
+import java.io.UnsupportedEncodingException;
+
+@Component
+public class PickCarProducer {
+    /**
+     * 生产者的组名
+     */
+    @Value("${apache.rocketmq.producer.producerGroup}")
+    private String producerGroup;
+
+    private DefaultMQProducer producer;
+    /**
+     * NameServer 地址
+     */
+    @Value("${apache.rocketmq.namesrvAddr}")
+    private String namesrvAddr;
+
+    @PostConstruct
+    public void defaultMQProducer() {
+
+        //生产者的组名
+        producer= new DefaultMQProducer(producerGroup);
+        //指定NameServer地址,多个地址以 ; 隔开
+        producer.setNamesrvAddr(namesrvAddr);
+        producer.setVipChannelEnabled(false);
+        try {
+            producer.start();
+            System.out.println("-------->:producer启动了");
+        } catch (MQClientException e) {
+            e.printStackTrace();
+        }
+    }
+
+    public String send(String topic,String tags,String body) throws InterruptedException, RemotingException, MQClientException, MQBrokerException, UnsupportedEncodingException {
+        Message message = new Message(topic, tags, body.getBytes(RemotingHelper.DEFAULT_CHARSET));
+        StopWatch stop = new StopWatch();
+        stop.start();
+        SendResult result = producer.send(message);
+        System.out.println("发送响应:MsgId:" + result.getMsgId() + ",发送状态:" + result.getSendStatus());
+        stop.stop();
+        return "{\"MsgId\":\""+result.getMsgId()+"\"}";
+    }
+}

+ 7 - 24
src/main/resources/application-dev.yml

@@ -161,27 +161,10 @@ ca-sign:
   rtms-server: http://192.0.33.104:8080
   ocr-server: http://192.6.33.2:1224
 
-wxpay:
-  #应用编号
-  appId: xxxxxxxxxxxxx
-
-  #商户号
-  mchId: xxxxxxxxxxxxx
-
-  # APIv3密钥
-  apiV3Key: xxxxxxxxxxxxx
-
-  # 支付通知回调, 本地测试内网穿透地址
-  notifyUrl: http://405c3382p5.goho.co:25325/wenbo-pay/notify/payNotify
-
-  # 退款通知回调,  本地测试内网穿透地址
-  refundNotifyUrl: http://405c3382p5.goho.co:25325/wenbo-pay/notify/refundNotify
-
-  # 密钥路径,resources根目录下
-  keyPemPath: apiclient_key.pem
-
-  # 商户证书序列号
-  serialNo: xxxxxxxxxxxxx
-
-  # 小程序密钥
-  appSecret: xxxxxxxxxxxxx
+apache:
+  rocketmq:
+    consumer:
+      pushConsumer: XiaourPushConsumer
+    producer:
+      producerGroup: Xiaour
+    namesrvAddr: 8.138.18.76:8086

+ 7 - 24
src/main/resources/application-prod.yml

@@ -159,27 +159,10 @@ ca-sign:
   rtms-server: http://192.0.33.104:8080
   ocr-server: http://192.6.33.2:1224
 
-wxpay:
-  #应用编号
-  appId: xxxxxxxxxxxxx
-
-  #商户号
-  mchId: xxxxxxxxxxxxx
-
-  # APIv3密钥
-  apiV3Key: xxxxxxxxxxxxx
-
-  # 支付通知回调, 本地测试内网穿透地址
-  notifyUrl: http://405c3382p5.goho.co:25325/wenbo-pay/notify/payNotify
-
-  # 退款通知回调,  本地测试内网穿透地址
-  refundNotifyUrl: http://405c3382p5.goho.co:25325/wenbo-pay/notify/refundNotify
-
-  # 密钥路径,resources根目录下
-  keyPemPath: apiclient_key.pem
-
-  # 商户证书序列号
-  serialNo: xxxxxxxxxxxxx
-
-  # 小程序密钥
-  appSecret: xxxxxxxxxxxxx
+apache:
+  rocketmq:
+    consumer:
+      pushConsumer: XiaourPushConsumer
+    producer:
+      producerGroup: Xiaour
+    namesrvAddr: 8.138.18.76:8086