Commit 564613d5 authored by dingzhiwei's avatar dingzhiwei
Browse files

优化阿里云rocketMQ

parent 8a2c815d
...@@ -76,12 +76,12 @@ spring: ...@@ -76,12 +76,12 @@ spring:
# producer: # producer:
# group: JEEPAY-GROUP # group: JEEPAY-GROUP
## 阿里云rocketmq配置 ( 注意:aliyun-rocketmq配置项请放置到根目录, 不是spring的二级配置! ) ## 阿里云rocketmq配置 ( 注意:aliyun-rocketmq配置项请放置到根目录, 不是spring的二级配置!需要阿里云开通rocketMQ产品,创建Group和Topic )
#aliyun-rocketmq: #aliyun-rocketmq:
# namesrvAddr: 127.0.0.1:9876 # namesrvAddr: xxx
# accessKey: accessKey # accessKey: xxx
# secretKey: secretKey # secretKey: xxx
# producerId: JEEPAY-GROUP # groupId: GID_JEEPAY_T
#日志配置参数。 #日志配置参数。
# 当存在logback-spring.xml文件时: 该配置将引进到logback配置, springboot配置不生效。 # 当存在logback-spring.xml文件时: 该配置将引进到logback配置, springboot配置不生效。
...@@ -98,7 +98,7 @@ isys: ...@@ -98,7 +98,7 @@ isys:
allow-cors: true allow-cors: true
#是否内存缓存配置信息: true表示开启如支付网关地址/商户应用配置/服务商配置等, 开启后需检查MQ的广播模式是否正常; false表示直接查询DB. #是否内存缓存配置信息: true表示开启如支付网关地址/商户应用配置/服务商配置等, 开启后需检查MQ的广播模式是否正常; false表示直接查询DB.
cache-config: false cache-config: true
oss: oss:
file-root-path: /home/jeepay/upload #存储根路径 ( 无需以‘/’结尾 ) file-root-path: /home/jeepay/upload #存储根路径 ( 无需以‘/’结尾 )
......
...@@ -86,14 +86,12 @@ spring: ...@@ -86,14 +86,12 @@ spring:
# producer: # producer:
# group: JEEPAY-GROUP # group: JEEPAY-GROUP
## 阿里云rocketmq配置 ( 注意:aliyun-rocketmq配置项请放置到根目录, 不是spring的二级配置! ) ## 阿里云rocketmq配置 ( 注意:aliyun-rocketmq配置项请放置到根目录, 不是spring的二级配置!需要阿里云开通rocketMQ产品,创建Group和Topic )
#aliyun-rocketmq: #aliyun-rocketmq:
# namesrvAddr: 127.0.0.1:9876 # namesrvAddr: xxx
# accessKey: accessKey # accessKey: xxx
# secretKey: secretKey # secretKey: xxx
# consumerId: JEEPAY-GROUP-MGR # groupId: GID_JEEPAY_T
# broadcastConsumerId: JEEPAY-GROUP-MGR-BROADCAST # 广播模式消费者ID
# producerId: JEEPAY-GROUP
#日志配置参数。 #日志配置参数。
# 当存在logback-spring.xml文件时: 该配置将引进到logback配置, springboot配置不生效。 # 当存在logback-spring.xml文件时: 该配置将引进到logback配置, springboot配置不生效。
......
...@@ -86,14 +86,12 @@ spring: ...@@ -86,14 +86,12 @@ spring:
# producer: # producer:
# group: JEEPAY-GROUP # group: JEEPAY-GROUP
## 阿里云rocketmq配置 ( 注意:aliyun-rocketmq配置项请放置到根目录, 不是spring的二级配置! ) ## 阿里云rocketmq配置 ( 注意:aliyun-rocketmq配置项请放置到根目录, 不是spring的二级配置!需要阿里云开通rocketMQ产品,创建Group和Topic )
#aliyun-rocketmq: #aliyun-rocketmq:
# namesrvAddr: 127.0.0.1:9876 # namesrvAddr: xxx
# accessKey: accessKey # accessKey: xxx
# secretKey: secretKey # secretKey: xxx
# consumerId: JEEPAY-GROUP-MCH # groupId: GID_JEEPAY_T
# broadcastConsumerId: JEEPAY-GROUP-MCH-BROADCAST # 广播模式消费者ID
# producerId: JEEPAY-GROUP
#日志配置参数。 #日志配置参数。
# 当存在logback-spring.xml文件时: 该配置将引进到logback配置, springboot配置不生效。 # 当存在logback-spring.xml文件时: 该配置将引进到logback配置, springboot配置不生效。
......
...@@ -86,14 +86,12 @@ spring: ...@@ -86,14 +86,12 @@ spring:
# producer: # producer:
# group: JEEPAY-GROUP # group: JEEPAY-GROUP
## 阿里云rocketmq配置 ( 注意:aliyun-rocketmq配置项请放置到根目录, 不是spring的二级配置! ) ## 阿里云rocketmq配置 ( 注意:aliyun-rocketmq配置项请放置到根目录, 不是spring的二级配置!需要阿里云开通rocketMQ产品,创建Group和Topic )
#aliyun-rocketmq: #aliyun-rocketmq:
# namesrvAddr: 127.0.0.1:9876 # namesrvAddr: xxx
# accessKey: accessKey # accessKey: xxx
# secretKey: secretKey # secretKey: xxx
# consumerId: JEEPAY-GROUP-PAY # groupId: GID_JEEPAY_T
# broadcastConsumerId: JEEPAY-GROUP-PAY-BROADCAST # 广播模式消费者ID
# producerId: JEEPAY-GROUP
#日志配置参数。 #日志配置参数。
......
...@@ -51,7 +51,6 @@ ...@@ -51,7 +51,6 @@
<!-- <scope>provided</scope>--> <!-- <scope>provided</scope>-->
</dependency> </dependency>
<!-- RabbitMQ --> <!-- RabbitMQ -->
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
......
...@@ -48,7 +48,7 @@ public abstract class AbstractAliYunRocketMQReceiver implements IMQMsgReceiver, ...@@ -48,7 +48,7 @@ public abstract class AbstractAliYunRocketMQReceiver implements IMQMsgReceiver,
public Action consume(Message message, ConsumeContext context) { public Action consume(Message message, ConsumeContext context) {
try { try {
receiveMsg(new String(message.getBody())); receiveMsg(new String(message.getBody()));
log.info("【{}】MQ消息消费成功topic:{}, messageId:{}", getConsumerName(), message.getTopic(), message.getMsgID()); log.debug("【{}】MQ消息消费成功topic:{}, messageId:{}", getConsumerName(), message.getTopic(), message.getMsgID());
return Action.CommitMessage; return Action.CommitMessage;
} catch (Exception e) { } catch (Exception e) {
log.error("【{}】MQ消息消费失败topic:{}, messageId:{}", getConsumerName(), message.getTopic(), message.getMsgID(), e); log.error("【{}】MQ消息消费失败topic:{}, messageId:{}", getConsumerName(), message.getTopic(), message.getMsgID(), e);
......
...@@ -22,17 +22,13 @@ public class AliYunRocketMQFactory { ...@@ -22,17 +22,13 @@ public class AliYunRocketMQFactory {
private String accessKey; private String accessKey;
@Value("${aliyun-rocketmq.secretKey}") @Value("${aliyun-rocketmq.secretKey}")
private String secretKey; private String secretKey;
@Value("${aliyun-rocketmq.consumerId}") @Value("${aliyun-rocketmq.groupId}")
private String consumerId; private String groupId;
@Value("${aliyun-rocketmq.broadcastConsumerId}")
private String broadcastConsumerId;
@Value("${aliyun-rocketmq.producerId}")
private String producerId;
@Bean(name = "producerClient") @Bean(name = "producerClient")
public Producer producerClient() { public Producer producerClient() {
Properties properties = new Properties(); Properties properties = new Properties();
properties.put(PropertyKeyConst.ProducerId, producerId); properties.put(PropertyKeyConst.GROUP_ID, groupId);
properties.put(PropertyKeyConst.AccessKey, accessKey); properties.put(PropertyKeyConst.AccessKey, accessKey);
properties.put(PropertyKeyConst.SecretKey, secretKey); properties.put(PropertyKeyConst.SecretKey, secretKey);
// 判断是否为空(生产环境走k8s集群环境变量自动注入,不获取本地配置文件的值) // 判断是否为空(生产环境走k8s集群环境变量自动注入,不获取本地配置文件的值)
...@@ -45,7 +41,7 @@ public class AliYunRocketMQFactory { ...@@ -45,7 +41,7 @@ public class AliYunRocketMQFactory {
@Bean(name = "consumerClient") @Bean(name = "consumerClient")
public Consumer consumerClient() { public Consumer consumerClient() {
Properties properties = new Properties(); Properties properties = new Properties();
properties.put(PropertyKeyConst.ConsumerId, consumerId); properties.put(PropertyKeyConst.GROUP_ID, groupId);
properties.put(PropertyKeyConst.AccessKey, accessKey); properties.put(PropertyKeyConst.AccessKey, accessKey);
properties.put(PropertyKeyConst.SecretKey, secretKey); properties.put(PropertyKeyConst.SecretKey, secretKey);
// 判断是否为空(生产环境走k8s集群环境变量自动注入,不获取本地配置文件的值) // 判断是否为空(生产环境走k8s集群环境变量自动注入,不获取本地配置文件的值)
...@@ -58,7 +54,7 @@ public class AliYunRocketMQFactory { ...@@ -58,7 +54,7 @@ public class AliYunRocketMQFactory {
@Bean(name = "broadcastConsumerClient") @Bean(name = "broadcastConsumerClient")
public Consumer broadcastConsumerClient() { public Consumer broadcastConsumerClient() {
Properties properties = new Properties(); Properties properties = new Properties();
properties.put(PropertyKeyConst.ConsumerId, broadcastConsumerId); properties.put(PropertyKeyConst.GROUP_ID, groupId);
properties.put(PropertyKeyConst.AccessKey, accessKey); properties.put(PropertyKeyConst.AccessKey, accessKey);
properties.put(PropertyKeyConst.SecretKey, secretKey); properties.put(PropertyKeyConst.SecretKey, secretKey);
// 广播订阅方式设置 // 广播订阅方式设置
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment