fixed: rabbitmq 链接异常造成 业务中断bug

This commit is contained in:
wangiegie@gmail.com 2017-11-19 22:54:10 +08:00
parent e9904f78ec
commit a9c7befdeb
1 changed files with 9 additions and 1 deletions

View File

@ -2,10 +2,13 @@ package com.github.pig.gateway.service.impl;
import com.github.pig.common.constant.CommonConstant;
import com.github.pig.gateway.service.LogSendService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.net.ConnectException;
import java.util.HashMap;
import java.util.Map;
@ -16,11 +19,16 @@ import java.util.Map;
*/
@Component
public class LogSendServiceImpl implements LogSendService {
private Logger logger = LoggerFactory.getLogger(LogSendServiceImpl.class);
@Autowired
private AmqpTemplate rabbitTemplate;
@Override
public void send() {
rabbitTemplate.convertAndSend(CommonConstant.LOG_QUEUE, "你好");
try {
rabbitTemplate.convertAndSend(CommonConstant.LOG_QUEUE, "你好");
} catch (Exception connectException) {
logger.error("rabbitMQ链接异常", connectException);
}
}
}