|
|
|
@ -1,21 +1,16 @@
|
|
|
|
|
package com.foreverwin.mesnac.common.util;
|
|
|
|
|
|
|
|
|
|
import com.foreverwin.modular.core.exception.BaseException;
|
|
|
|
|
import org.json.JSONObject;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
|
|
|
|
import org.springframework.jms.core.JmsMessagingTemplate;
|
|
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
|
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @Description TODO
|
|
|
|
|
* @Author zhaojiawei
|
|
|
|
|
* @Since 2021-07-21
|
|
|
|
|
*/
|
|
|
|
|
@Component
|
|
|
|
|
@ConditionalOnProperty(prefix = "activeMq", value = {"enabled"}, matchIfMissing = true)
|
|
|
|
|
public class ActiveMQUtil {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -28,16 +23,13 @@ public class ActiveMQUtil {
|
|
|
|
|
try{
|
|
|
|
|
jsonObject.put("TO_USER", user);
|
|
|
|
|
jsonObject.put("CONTENT",text);
|
|
|
|
|
defaultJmsTemplate.getJmsTemplate().setReceiveTimeout(TimeUnit.SECONDS.toMillis(3));
|
|
|
|
|
String message = defaultJmsTemplate.convertSendAndReceive(queue, jsonObject.toString(), String.class);
|
|
|
|
|
if (StringUtil.isBlank(message)) {
|
|
|
|
|
//记日志
|
|
|
|
|
}
|
|
|
|
|
// defaultJmsTemplate.getJmsTemplate().setReceiveTimeout(TimeUnit.SECONDS.toMillis(3));
|
|
|
|
|
defaultJmsTemplate.convertAndSend(queue, jsonObject.toString());
|
|
|
|
|
// if (StringUtil.isBlank(message)) {
|
|
|
|
|
// //记日志
|
|
|
|
|
// }
|
|
|
|
|
}catch (Exception ignored){
|
|
|
|
|
throw new BaseException("消息发送失败");
|
|
|
|
|
// throw new BaseException("消息发送失败");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|