mirror of https://gitee.com/maxjhandsome/pig
fixed: rabbitmq 链接异常造成 业务中断bug
This commit is contained in:
parent
e9904f78ec
commit
a9c7befdeb
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue