Commit a4c5c6a5 authored by yanzg's avatar yanzg

修改MQ请求尸体,防止出错

parent 64d7633a
...@@ -84,7 +84,7 @@ public class YzgMqConsumer { ...@@ -84,7 +84,7 @@ public class YzgMqConsumer {
*/ */
public String sendDelay(String json, long dedTime) { public String sendDelay(String json, long dedTime) {
if (dedTime > 0) { if (dedTime > 0) {
return mqService.message(new MessageVo(YZG_MQ_SYSTEM_QUEUE_DELAY, YZG_MQ_SYSTEM_QUEUE_DELAY, json, dedTime, true)); return mqService.message(new MessageVo(YZG_MQ_SYSTEM_QUEUE_DELAY, YZG_MQ_SYSTEM_QUEUE_DELAY, json, dedTime));
} else { } else {
return mqService.message(new MessageVo(YZG_MQ_SYSTEM_QUEUE, YZG_MQ_SYSTEM_QUEUE, json)); return mqService.message(new MessageVo(YZG_MQ_SYSTEM_QUEUE, YZG_MQ_SYSTEM_QUEUE, json));
} }
......
...@@ -69,7 +69,7 @@ public class MessageServiceImpl implements MessageService { ...@@ -69,7 +69,7 @@ public class MessageServiceImpl implements MessageService {
if (!StringHelper.isEmpty(req.getHandleTime())) { if (!StringHelper.isEmpty(req.getHandleTime())) {
long dedTime = DateHelper.getDateTime(req.getHandleTime()).getTime() - System.currentTimeMillis(); long dedTime = DateHelper.getDateTime(req.getHandleTime()).getTime() - System.currentTimeMillis();
req.setDedTime(dedTime); req.setDedTime(dedTime);
req.setDedTimeDefine(false); // req.setDedTimeDefine(false);
// return messageDao.save(req); // return messageDao.save(req);
} }
return sendContent(StringHelper.EMPTY, req, now); return sendContent(StringHelper.EMPTY, req, now);
...@@ -94,11 +94,14 @@ public class MessageServiceImpl implements MessageService { ...@@ -94,11 +94,14 @@ public class MessageServiceImpl implements MessageService {
* @return * @return
*/ */
private String sendContent(String messageId, MessageVo req, boolean now) { private String sendContent(String messageId, MessageVo req, boolean now) {
if (req.getDedTime() > 0 && !req.isDedTimeDefine() && !now) { if (!StringHelper.compare(req.getExchangeName(), YzgMqConsumer.YZG_MQ_SYSTEM_QUEUE_DELAY)
&& !StringHelper.compare(req.getExchangeName(), YzgMqConsumer.YZG_MQ_SYSTEM_QUEUE)) {
if (req.getDedTime() > 0 && !now) {
// 延迟队列处理 // 延迟队列处理
req.setMessageId(messageId); req.setMessageId(messageId);
return yzgMqConsumer.sendDelay(req); return yzgMqConsumer.sendDelay(req);
} }
}
messageId = StringHelper.getFirst(messageId, StringHelper.getId("temp", StringHelper.getNewID())); messageId = StringHelper.getFirst(messageId, StringHelper.getId("temp", StringHelper.getNewID()));
......
...@@ -35,11 +35,6 @@ public class MessageVo extends BaseVo implements InitDao { ...@@ -35,11 +35,6 @@ public class MessageVo extends BaseVo implements InitDao {
*/ */
private String message; private String message;
/**
* 手动定义延迟队列
*/
private boolean dedTimeDefine;
/** /**
* 延迟毫秒 * 延迟毫秒
*/ */
...@@ -132,33 +127,6 @@ public class MessageVo extends BaseVo implements InitDao { ...@@ -132,33 +127,6 @@ public class MessageVo extends BaseVo implements InitDao {
this.dedTime = dedTime; this.dedTime = dedTime;
} }
/**
* 构造函数
*
* @param exchangeNameRouteKey 交换器名称+路由键
* @param message 消息内容
* @param dedTime 过期时间
*/
public MessageVo(String exchangeNameRouteKey, String message, long dedTime, boolean dedTimeDefine) {
this(exchangeNameRouteKey, exchangeNameRouteKey, message, dedTime, dedTimeDefine);
}
/**
* 构造函数
*
* @param exchangeName 交换器名称
* @param routeKey 路由键
* @param message 消息内容
* @param dedTime 过期时间
*/
public MessageVo(String exchangeName, String routeKey, String message, long dedTime, boolean dedTimeDefine) {
this.exchangeName = exchangeName;
this.routeKey = routeKey;
this.message = message;
this.dedTime = dedTime;
this.dedTimeDefine = dedTimeDefine;
}
/** /**
* 构造函数 * 构造函数
* *
...@@ -214,14 +182,6 @@ public class MessageVo extends BaseVo implements InitDao { ...@@ -214,14 +182,6 @@ public class MessageVo extends BaseVo implements InitDao {
this.dedTime = dedTime; this.dedTime = dedTime;
} }
public boolean isDedTimeDefine() {
return dedTimeDefine;
}
public void setDedTimeDefine(boolean dedTimeDefine) {
this.dedTimeDefine = dedTimeDefine;
}
public int getHandleCount() { public int getHandleCount() {
return handleCount; return handleCount;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment