Commit e83d2ada authored by yanzg's avatar yanzg

接口文档的支持

parent f579a8e8
......@@ -101,6 +101,7 @@ public interface MqService {
/**
* 发送给指定服务器消息
*
* @param req
* @return
*/
@ApiOperation(value = "发送给指定服务器消息")
......
......@@ -29,6 +29,8 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
/**
* 消息队列服务实现类
......@@ -243,6 +245,7 @@ public class MqServiceImpl implements MqService {
/**
* 删除token的执行
*
* @param req
*/
@ApiOperation(value = "删除token的执行")
......@@ -257,27 +260,37 @@ public class MqServiceImpl implements MqService {
/**
* 发送给指定服务器消息
*
* @param req
* @return
*/
@ApiOperation(value = "发送给指定服务器消息")
@Override
public String sendServerMessage(ServerMessageReqVo req) {
String queueName = req.getQueueName();
String localQueueName = this.getLocalName(req.getQueueName());
String serverId = StringHelper.getMD5Id(localQueueName);
String serverTokenId = StringHelper.getMD5Id(req.getToken(), queueName);
if (req.isNext()) {
throw new CodeException("达到最大次数,不会继续发送");
}
String sendQueueName = StringHelper.EMPTY;
String queueName = req.getQueueName();
List<String> sendQueueName = new ArrayList<>();
try {
if (!StringHelper.isEmpty(req.getToken())) {
String serverTokenId = StringHelper.getMD5Id(req.getToken(), queueName);
// 获取token所在服务器
QueueServerTokenVo tokenVo = queueServerTokenDao.load(serverTokenId, QueueServerTokenVo.class);
if (tokenVo != null) {
// 获取服务器的队列名称
QueueServerVo server = queueServerDao.load(tokenVo.getServerId(), QueueServerVo.class);
if (server != null) {
sendQueueName = server.getQueueServer();
sendQueueName.add(server.getQueueServer());
}
}
} else {
// 获取服务器的队列名称
QueueServerVo loadReq = new QueueServerVo();
loadReq.setQueueName(queueName);
List<QueueServerVo> servers = queueServerDao.loadList(loadReq, QueueServerVo.class);
for (QueueServerVo server : servers) {
sendQueueName.add(server.getQueueServer());
}
}
} catch (Exception ex) {
......@@ -287,10 +300,14 @@ public class MqServiceImpl implements MqService {
// 发送消息,等待下次重新发送
req.addPos();
String json = JsonHelper.serialize(req);
if (StringHelper.isEmpty(sendQueueName)) {
if (sendQueueName.isEmpty()) {
return this.message(new MessageVo(req.getQueueName(), req.getQueueName(), json, req.getNextDelayTime()));
} else {
return this.message(new MessageVo(sendQueueName, sendQueueName, json));
String ret = StringHelper.EMPTY;
for (String name : sendQueueName) {
ret = this.message(new MessageVo(name, name, json));
}
return ret;
}
}
......
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