Commit 4b36cc4e authored by yanzg's avatar yanzg

修改实例化关系

parent 068a6d24
...@@ -2,7 +2,6 @@ package com.yanzuoguang.mq.plan; ...@@ -2,7 +2,6 @@ package com.yanzuoguang.mq.plan;
import com.rabbitmq.client.Channel; import com.rabbitmq.client.Channel;
import com.yanzuoguang.mq.service.MqService; import com.yanzuoguang.mq.service.MqService;
import com.yanzuoguang.mq.service.QueueService;
import com.yanzuoguang.mq.vo.MessagePlan; import com.yanzuoguang.mq.vo.MessagePlan;
import com.yanzuoguang.mq.vo.MessageVo; import com.yanzuoguang.mq.vo.MessageVo;
import com.yanzuoguang.mq.vo.req.RegisterServerTokenReqVo; import com.yanzuoguang.mq.vo.req.RegisterServerTokenReqVo;
......
...@@ -33,6 +33,23 @@ public interface MqService { ...@@ -33,6 +33,23 @@ public interface MqService {
@ApiOperation(value = "发送消息") @ApiOperation(value = "发送消息")
String message(MessageVo req); String message(MessageVo req);
/**
* 写入当前对象
*
* @param message 当前消息的内容
* @return
*/
@ApiOperation(value = "写入当前对象")
void logCurrent(Message message);
/**
* 删除当前对象
*
* @return
*/
@ApiOperation(value = "写入当前对象")
void logCurrentRemove();
/** /**
* 记录一个消息已完成 * 记录一个消息已完成
......
...@@ -21,6 +21,7 @@ import com.yanzuoguang.util.helper.UrlHelper; ...@@ -21,6 +21,7 @@ import com.yanzuoguang.util.helper.UrlHelper;
import com.yanzuoguang.util.log.Log; import com.yanzuoguang.util.log.Log;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.springframework.amqp.core.Message; import org.springframework.amqp.core.Message;
import org.springframework.amqp.core.MessageProperties;
import org.springframework.amqp.rabbit.core.ChannelAwareMessageListener; import org.springframework.amqp.rabbit.core.ChannelAwareMessageListener;
import org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer; import org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer;
import org.springframework.beans.BeansException; import org.springframework.beans.BeansException;
...@@ -53,6 +54,8 @@ public class MqServiceImpl implements MqService, ApplicationContextAware, MqInit ...@@ -53,6 +54,8 @@ public class MqServiceImpl implements MqService, ApplicationContextAware, MqInit
private YzgMqProcedure yzgMqProcedure; private YzgMqProcedure yzgMqProcedure;
private String localName = ""; private String localName = "";
private ThreadLocal<Message> localMessage = new ThreadLocal<>();
/** /**
* Set the ApplicationContext that this object runs in. * Set the ApplicationContext that this object runs in.
* Normally this call will be used to initialize the object. * Normally this call will be used to initialize the object.
...@@ -118,6 +121,28 @@ public class MqServiceImpl implements MqService, ApplicationContextAware, MqInit ...@@ -118,6 +121,28 @@ public class MqServiceImpl implements MqService, ApplicationContextAware, MqInit
return this.message(req, false); return this.message(req, false);
} }
/**
* 写入当前对象
*
* @param message 当前消息的内容
* @return
*/
@Override
public void logCurrent(Message message) {
localMessage.set(message);
}
/**
* 删除当前对象
*
* @return
*/
@Override
public void logCurrentRemove() {
localMessage.remove();
}
/** /**
* 记录一个消息已完成 * 记录一个消息已完成
* *
...@@ -125,7 +150,12 @@ public class MqServiceImpl implements MqService, ApplicationContextAware, MqInit ...@@ -125,7 +150,12 @@ public class MqServiceImpl implements MqService, ApplicationContextAware, MqInit
*/ */
@Override @Override
public String log() { public String log() {
throw new CodeException("该函数暂时未实现"); Message message = localMessage.get();
if (message == null) {
throw new CodeException("当前队列没有消息");
}
MessageProperties messageProperties = message.getMessageProperties();
return this.log(new MessageLogReqVo(messageProperties.getConsumerQueue(), messageProperties.getMessageId()));
} }
/** /**
......
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