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

优化阿里云rocketMQ

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