|
@@ -18,7 +18,6 @@ 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.StudentActive;
|
|
import cn.com.qmth.examcloud.core.reports.base.util.online.StudentLogin;
|
|
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.UserActive;
|
|
-import cn.com.qmth.examcloud.reports.commons.bean.LoginStudentReport;
|
|
|
|
import cn.com.qmth.examcloud.reports.commons.bean.OnlineExamStudentReport;
|
|
import cn.com.qmth.examcloud.reports.commons.bean.OnlineExamStudentReport;
|
|
import cn.com.qmth.examcloud.reports.commons.bean.OnlineStudentReport;
|
|
import cn.com.qmth.examcloud.reports.commons.bean.OnlineStudentReport;
|
|
import cn.com.qmth.examcloud.reports.commons.bean.OnlineUserReport;
|
|
import cn.com.qmth.examcloud.reports.commons.bean.OnlineUserReport;
|
|
@@ -32,10 +31,10 @@ public class KafkaConsumerListener {
|
|
|
|
|
|
static {
|
|
static {
|
|
props = new Properties();
|
|
props = new Properties();
|
|
- props.put("group.id", PropertyHolder.getString("spring.kafka.consumer.group-id"));
|
|
|
|
- props.put("bootstrap.servers", PropertyHolder.getString("spring.kafka.bootstrap-servers"));
|
|
|
|
- props.put("key.deserializer", PropertyHolder.getString("spring.kafka.consumer.key-deserializer"));
|
|
|
|
- props.put("value.deserializer", PropertyHolder.getString("spring.kafka.consumer.value-deserializer"));
|
|
|
|
|
|
+ props.put("group.id", "online-count-group");
|
|
|
|
+ props.put("bootstrap.servers", PropertyHolder.getString("$kafka-bootstrap-servers"));
|
|
|
|
+ props.put("key.deserializer", PropertyHolder.getString("$kafka-key-deserializer"));
|
|
|
|
+ props.put("value.deserializer", PropertyHolder.getString("$kafka-value-deserializer"));
|
|
}
|
|
}
|
|
|
|
|
|
public static void start() {
|
|
public static void start() {
|
|
@@ -44,7 +43,6 @@ public class KafkaConsumerListener {
|
|
subs.add(Topic.STUDENT.getCode());
|
|
subs.add(Topic.STUDENT.getCode());
|
|
subs.add(Topic.EXAM_STUDENT.getCode());
|
|
subs.add(Topic.EXAM_STUDENT.getCode());
|
|
subs.add(Topic.USER.getCode());
|
|
subs.add(Topic.USER.getCode());
|
|
- subs.add(Topic.STUDENT_LOGIN.getCode());
|
|
|
|
consumer.subscribe(subs);
|
|
consumer.subscribe(subs);
|
|
try {
|
|
try {
|
|
for(;;) {
|
|
for(;;) {
|
|
@@ -60,12 +58,12 @@ public class KafkaConsumerListener {
|
|
onMessageExamStudent(record.value());
|
|
onMessageExamStudent(record.value());
|
|
}else if(Topic.USER.getCode().equals(record.topic())){
|
|
}else if(Topic.USER.getCode().equals(record.topic())){
|
|
onMessageUser(record.value());
|
|
onMessageUser(record.value());
|
|
- }else if(Topic.STUDENT_LOGIN.getCode().equals(record.topic())){
|
|
|
|
- onMessageLoginStudent(record.value());
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- } finally {
|
|
|
|
|
|
+ } catch(Exception e){
|
|
|
|
+ logger.error("消息消费线程出错",e);
|
|
|
|
+ }finally {
|
|
// 关闭消费者,网络连接和 socket 也会随之关闭,并立即触发一次再均衡
|
|
// 关闭消费者,网络连接和 socket 也会随之关闭,并立即触发一次再均衡
|
|
consumer.close();
|
|
consumer.close();
|
|
}
|
|
}
|
|
@@ -79,6 +77,7 @@ public class KafkaConsumerListener {
|
|
ac.setRootOrgId(r.getRootOrgId());
|
|
ac.setRootOrgId(r.getRootOrgId());
|
|
ac.setStudentId(r.getStudentId());
|
|
ac.setStudentId(r.getStudentId());
|
|
ActiveDataUtil.updateStudentActive(ac);
|
|
ActiveDataUtil.updateStudentActive(ac);
|
|
|
|
+ onMessageLoginStudent(r.getReportTime().getTime(), r.getRootOrgId(), r.getStudentId());
|
|
}
|
|
}
|
|
|
|
|
|
private static void onMessageExamStudent(String message) {
|
|
private static void onMessageExamStudent(String message) {
|
|
@@ -87,9 +86,10 @@ public class KafkaConsumerListener {
|
|
ExamStudentActive ac = new ExamStudentActive();
|
|
ExamStudentActive ac = new ExamStudentActive();
|
|
ac.setActiveTime(r.getReportTime().getTime());
|
|
ac.setActiveTime(r.getReportTime().getTime());
|
|
ac.setRootOrgId(r.getRootOrgId());
|
|
ac.setRootOrgId(r.getRootOrgId());
|
|
- ac.setExamStudentId(r.getExamStudentId());
|
|
|
|
|
|
+ ac.setStudentId(r.getStudentId());
|
|
ac.setExamId(r.getExamId());
|
|
ac.setExamId(r.getExamId());
|
|
ActiveDataUtil.updateExamStudentActive(ac);
|
|
ActiveDataUtil.updateExamStudentActive(ac);
|
|
|
|
+ onMessageLoginStudent(r.getReportTime().getTime(), r.getRootOrgId(), r.getStudentId());
|
|
}
|
|
}
|
|
|
|
|
|
private static void onMessageUser(String message) {
|
|
private static void onMessageUser(String message) {
|
|
@@ -102,13 +102,11 @@ public class KafkaConsumerListener {
|
|
ActiveDataUtil.updateUserActive(ac);
|
|
ActiveDataUtil.updateUserActive(ac);
|
|
}
|
|
}
|
|
|
|
|
|
- private static void onMessageLoginStudent(String message) {
|
|
|
|
- logger.debug("STUDENT_LOGIN message:" + message);
|
|
|
|
- LoginStudentReport r = JSON.parseObject(message, LoginStudentReport.class);
|
|
|
|
|
|
+ private static void onMessageLoginStudent(Long reportTime,Long rootOrgId,Long studentId) {
|
|
StudentLogin sl = new StudentLogin();
|
|
StudentLogin sl = new StudentLogin();
|
|
- sl.setActiveTime(r.getReportTime().getTime());
|
|
|
|
- sl.setRootOrgId(r.getRootOrgId());
|
|
|
|
- sl.setStudentId(r.getStudentId());
|
|
|
|
|
|
+ sl.setActiveTime(reportTime);
|
|
|
|
+ sl.setRootOrgId(rootOrgId);
|
|
|
|
+ sl.setStudentId(studentId);
|
|
ActiveDataUtil.updateStudentlogin(sl);
|
|
ActiveDataUtil.updateStudentlogin(sl);
|
|
}
|
|
}
|
|
|
|
|