Commit 2975ef98 authored by yanzg's avatar yanzg

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

parent 0252e680
...@@ -11,6 +11,7 @@ import com.yanzuoguang.util.helper.StringHelper; ...@@ -11,6 +11,7 @@ import com.yanzuoguang.util.helper.StringHelper;
import com.yanzuoguang.util.log.Log; import com.yanzuoguang.util.log.Log;
import org.springframework.amqp.core.Message; import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitListener; import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
...@@ -23,7 +24,7 @@ import java.util.Map; ...@@ -23,7 +24,7 @@ import java.util.Map;
* @author 颜佐光 * @author 颜佐光
*/ */
@Component @Component
public class YzgMqConsumer { public class YzgMqConsumer implements InitializingBean {
private static class TimeUnit { private static class TimeUnit {
public String tag; public String tag;
...@@ -66,6 +67,22 @@ public class YzgMqConsumer { ...@@ -66,6 +67,22 @@ public class YzgMqConsumer {
private Map<String, Boolean> cacheQueueName = new HashMap<>(); private Map<String, Boolean> cacheQueueName = new HashMap<>();
/**
* Invoked by a BeanFactory after it has set all bean properties supplied
* (and satisfied BeanFactoryAware and ApplicationContextAware).
* <p>This method allows the bean instance to perform initialization only
* possible when all bean properties have been set and to throw an
* exception in the event of misconfiguration.
*
* @throws Exception in the event of misconfiguration (such
* as failure to set an essential property) or if initialization fails.
*/
@Override
public void afterPropertiesSet() throws Exception {
mqService.createQueue(new QueueVo(YZG_MQ_SYSTEM_QUEUE));
}
/** /**
* MQ回调 * MQ回调
* *
......
...@@ -79,7 +79,7 @@ public class MqServiceImpl implements MqService, InitializingBean { ...@@ -79,7 +79,7 @@ public class MqServiceImpl implements MqService, InitializingBean {
} }
this.localName = UrlHelper.getIp(); this.localName = UrlHelper.getIp();
QueueVo removeToken = new QueueVo(YzgMqConsumer.YZG_MQ_CLEAR_TOKEN_QUEUE, YzgMqConsumer.YZG_MQ_CLEAR_TOKEN_QUEUE, YzgMqConsumer.YZG_MQ_CLEAR_TOKEN_QUEUE); QueueVo removeToken = new QueueVo(YzgMqConsumer.YZG_MQ_CLEAR_TOKEN_QUEUE);
removeToken.check(); removeToken.check();
queueService.create(removeToken); queueService.create(removeToken);
......
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