|
@@ -1,25 +1,17 @@
|
|
|
package cn.com.qmth.examcloud.core.basic.service.report;
|
|
|
|
|
|
-import java.util.Properties;
|
|
|
-
|
|
|
-import org.slf4j.Logger;
|
|
|
-import org.slf4j.LoggerFactory;
|
|
|
-
|
|
|
-import com.alibaba.fastjson.JSON;
|
|
|
-import com.aliyun.openservices.ons.api.Action;
|
|
|
-import com.aliyun.openservices.ons.api.ConsumeContext;
|
|
|
-import com.aliyun.openservices.ons.api.Consumer;
|
|
|
-import com.aliyun.openservices.ons.api.Message;
|
|
|
-import com.aliyun.openservices.ons.api.MessageListener;
|
|
|
-import com.aliyun.openservices.ons.api.ONSFactory;
|
|
|
-import com.aliyun.openservices.ons.api.PropertyKeyConst;
|
|
|
-
|
|
|
import cn.com.qmth.examcloud.core.basic.service.AdminOperateService;
|
|
|
import cn.com.qmth.examcloud.reports.commons.bean.AdminOperateReport;
|
|
|
import cn.com.qmth.examcloud.reports.commons.enums.Tag;
|
|
|
import cn.com.qmth.examcloud.reports.commons.util.ReportsUtil;
|
|
|
import cn.com.qmth.examcloud.web.bootstrap.PropertyHolder;
|
|
|
import cn.com.qmth.examcloud.web.support.SpringContextHolder;
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
+import com.aliyun.openservices.ons.api.*;
|
|
|
+import org.slf4j.Logger;
|
|
|
+import org.slf4j.LoggerFactory;
|
|
|
+
|
|
|
+import java.util.Properties;
|
|
|
|
|
|
public class RocketMqConsumerListener {
|
|
|
|
|
@@ -30,17 +22,19 @@ public class RocketMqConsumerListener {
|
|
|
private static Properties properties = new Properties();
|
|
|
|
|
|
static {
|
|
|
- properties.put(PropertyKeyConst.AccessKey, PropertyHolder.getString("$rocketmq-accesskey"));
|
|
|
+ properties.put(PropertyKeyConst.AccessKey, PropertyHolder.getString("examcloud.rocketmq.accesskey"));
|
|
|
|
|
|
- properties.put(PropertyKeyConst.SecretKey, PropertyHolder.getString("$rocketmq-secretkey"));
|
|
|
+ properties.put(PropertyKeyConst.SecretKey, PropertyHolder.getString("examcloud.rocketmq.secretkey"));
|
|
|
|
|
|
properties.setProperty(PropertyKeyConst.SendMsgTimeoutMillis, "3000");
|
|
|
|
|
|
- properties.put(PropertyKeyConst.NAMESRV_ADDR, PropertyHolder.getString("$rocketmq-namesrv-addr"));
|
|
|
+ properties.put(PropertyKeyConst.NAMESRV_ADDR, PropertyHolder.getString("examcloud.rocketmq.namesrv_addr"));
|
|
|
|
|
|
properties.put(PropertyKeyConst.SuspendTimeMillis, "100");
|
|
|
|
|
|
properties.put(PropertyKeyConst.MaxReconsumeTimes, "10");
|
|
|
+
|
|
|
+ properties.put(PropertyKeyConst.GROUP_ID, PropertyHolder.getString("examcloud.rocketmq.consumer_group"));
|
|
|
}
|
|
|
|
|
|
public static void start() {
|
|
@@ -48,7 +42,6 @@ public class RocketMqConsumerListener {
|
|
|
}
|
|
|
|
|
|
private static void adminOperate() {
|
|
|
- properties.put(PropertyKeyConst.GROUP_ID, Tag.ADMIN_OPERATE_INFO.getGroup());
|
|
|
Consumer consumer = ONSFactory.createConsumer(properties);
|
|
|
consumer.subscribe(ReportsUtil.getReportTopic(), Tag.ADMIN_OPERATE_INFO.getCode(), new MessageListener() {
|
|
|
|
|
@@ -63,7 +56,6 @@ public class RocketMqConsumerListener {
|
|
|
return Action.ReconsumeLater;
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
});
|
|
|
|
|
|
consumer.start();
|
|
@@ -73,4 +65,5 @@ public class RocketMqConsumerListener {
|
|
|
AdminOperateReport r = JSON.parseObject(message, AdminOperateReport.class);
|
|
|
adminOperateService.saveOperate(r, msgId);
|
|
|
}
|
|
|
+
|
|
|
}
|