|
@@ -1,5 +1,6 @@
|
|
|
package cn.com.qmth.examcloud.reports.commons.util;
|
|
|
|
|
|
+import cn.com.qmth.examcloud.commons.exception.StatusException;
|
|
|
import cn.com.qmth.examcloud.commons.util.ThreadLocalUtil;
|
|
|
import cn.com.qmth.examcloud.reports.commons.bean.BaseReport;
|
|
|
import cn.com.qmth.examcloud.reports.commons.enums.MqType;
|
|
@@ -9,6 +10,7 @@ import cn.com.qmth.examcloud.web.support.ServletUtil;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.aliyun.openservices.ons.api.*;
|
|
|
import org.apache.commons.collections.CollectionUtils;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
|
@@ -53,7 +55,6 @@ public class ReportsUtil {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
private static void sendReportRocket(Boolean onException) {
|
|
|
@SuppressWarnings("unchecked")
|
|
|
List<BaseReport> list = (List<BaseReport>) ThreadLocalUtil.get(KEY);
|
|
@@ -64,6 +65,7 @@ public class ReportsUtil {
|
|
|
String messageStr = JSON.toJSONString(b);
|
|
|
Message msg = new Message(b.getTopic(), b.getTag(), messageStr.getBytes("utf-8"));
|
|
|
producer.sendAsync(msg, new SendCallback() {
|
|
|
+
|
|
|
@Override
|
|
|
public void onSuccess(final SendResult sendResult) {
|
|
|
// 消息发送成功。
|
|
@@ -121,4 +123,11 @@ public class ReportsUtil {
|
|
|
report.setReportTime(new Date());
|
|
|
}
|
|
|
|
|
|
+ public static String getReportTopic() {
|
|
|
+ String topic = PropertyHolder.getString("$report.mq-topic");
|
|
|
+ if (StringUtils.isBlank(topic)) {
|
|
|
+ throw new StatusException("$report.mq-topic 未配置");
|
|
|
+ }
|
|
|
+ return topic;
|
|
|
+ }
|
|
|
}
|