|
@@ -1,24 +1,6 @@
|
|
|
package cn.com.qmth.examcloud.core.reports.api.listener;
|
|
|
|
|
|
-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.reports.base.util.online.ActiveDataUtil;
|
|
|
-import cn.com.qmth.examcloud.core.reports.base.util.online.ExamStudentActive;
|
|
|
-import cn.com.qmth.examcloud.core.reports.base.util.online.StudentActive;
|
|
|
-import cn.com.qmth.examcloud.core.reports.base.util.online.StudentLogin;
|
|
|
-import cn.com.qmth.examcloud.core.reports.base.util.online.UserActive;
|
|
|
+import cn.com.qmth.examcloud.core.reports.base.util.online.*;
|
|
|
import cn.com.qmth.examcloud.core.reports.service.OperateService;
|
|
|
import cn.com.qmth.examcloud.reports.commons.bean.OnlineExamStudentReport;
|
|
|
import cn.com.qmth.examcloud.reports.commons.bean.OnlineStudentReport;
|
|
@@ -28,6 +10,12 @@ 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 {
|
|
|
|
|
@@ -36,18 +24,21 @@ public class RocketMqConsumerListener {
|
|
|
private static OperateService operateService = SpringContextHolder.getBean(OperateService.class);
|
|
|
|
|
|
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() {
|
|
@@ -58,7 +49,6 @@ public class RocketMqConsumerListener {
|
|
|
}
|
|
|
|
|
|
private static void onlineExamStudent() {
|
|
|
- properties.put(PropertyKeyConst.GROUP_ID, Tag.ONLINE_EXAM_STUDENT.getGroup());
|
|
|
Consumer consumer = ONSFactory.createConsumer(properties);
|
|
|
consumer.subscribe(ReportsUtil.getReportTopic(), Tag.ONLINE_EXAM_STUDENT.getCode(), new MessageListener() {
|
|
|
|
|
@@ -73,14 +63,12 @@ public class RocketMqConsumerListener {
|
|
|
return Action.ReconsumeLater;
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
});
|
|
|
|
|
|
consumer.start();
|
|
|
}
|
|
|
|
|
|
private static void onlineStudent() {
|
|
|
- properties.put(PropertyKeyConst.GROUP_ID, Tag.ONLINE_STUDENT.getGroup());
|
|
|
Consumer consumer = ONSFactory.createConsumer(properties);
|
|
|
consumer.subscribe(ReportsUtil.getReportTopic(), Tag.ONLINE_STUDENT.getCode(), new MessageListener() {
|
|
|
|
|
@@ -95,14 +83,12 @@ public class RocketMqConsumerListener {
|
|
|
return Action.ReconsumeLater;
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
});
|
|
|
|
|
|
consumer.start();
|
|
|
}
|
|
|
|
|
|
private static void onlineUser() {
|
|
|
- properties.put(PropertyKeyConst.GROUP_ID, Tag.ONLINE_USER.getGroup());
|
|
|
Consumer consumer = ONSFactory.createConsumer(properties);
|
|
|
consumer.subscribe(ReportsUtil.getReportTopic(), Tag.ONLINE_USER.getCode(), new MessageListener() {
|
|
|
|
|
@@ -117,14 +103,12 @@ public class RocketMqConsumerListener {
|
|
|
return Action.ReconsumeLater;
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
});
|
|
|
|
|
|
consumer.start();
|
|
|
}
|
|
|
|
|
|
private static void operateInfo() {
|
|
|
- properties.put(PropertyKeyConst.GROUP_ID, Tag.OPERATE_INFO.getGroup());
|
|
|
Consumer consumer = ONSFactory.createConsumer(properties);
|
|
|
consumer.subscribe(ReportsUtil.getReportTopic(), Tag.OPERATE_INFO.getCode(), new MessageListener() {
|
|
|
|
|
@@ -139,7 +123,6 @@ public class RocketMqConsumerListener {
|
|
|
return Action.ReconsumeLater;
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
});
|
|
|
|
|
|
consumer.start();
|
|
@@ -196,4 +179,5 @@ public class RocketMqConsumerListener {
|
|
|
OperateReport r = JSON.parseObject(message, OperateReport.class);
|
|
|
operateService.saveOperate(r, msgId);
|
|
|
}
|
|
|
-}
|
|
|
+
|
|
|
+}
|