[agent][init]- fix bugs

This commit is contained in:
zeaslity
2023-02-28 10:34:48 +08:00
parent 593d5c1b77
commit f43d9f84a4
3 changed files with 24 additions and 6 deletions

View File

@@ -9,7 +9,6 @@ import io.wdd.common.beans.rabbitmq.OctopusMessage;
import io.wdd.common.handler.MyRuntimeException;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.checkerframework.checker.units.qual.K;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.*;
import org.springframework.amqp.support.AmqpHeaders;
@@ -88,7 +87,9 @@ public class OctopusAgentInitService {
// response chain to handle all kind of type of octopus message
if (!octopusMessageHandler.handle(octopusMessage)) {
throw new MyRuntimeException(" Handle Octopus Message Error !");
String s = "Handle Octopus Message Error !";
log.error(s);
throw new MyRuntimeException(s);
}
} catch (Exception e) {
@@ -98,8 +99,7 @@ public class OctopusAgentInitService {
// long deliveryTag, boolean requeue
// channel.basicReject(deliveryTag,true);
log.error("Octopus Agent Initialization Error, please check !");
log.info("waiting for 5 seconds");
log.error("Octopus Agent Initialization Error, please check ! Waiting for 5 seconds");
// 这里只是便于出现死循环时查看
TimeUnit.SECONDS.sleep(5);

View File

@@ -49,8 +49,11 @@ public class GenOctopusRabbitMQConnection {
// reboot judgement of existing exchange
QueueInformation queueInfo = rabbitAdmin.getQueueInfo(agentTopicName);
if (ObjectUtils.isNotEmpty(queueInfo) && queueInfo.getConsumerCount() > 0 ) {
log.info("Octopus Agent Specific Topic Queue Already Existed ! == {}", agentTopicName);
if (ObjectUtils.isNotEmpty(queueInfo)) {
log.info(
"Octopus Agent Specific Topic Queue Already Existed ! == {}",
agentTopicName
);
return;
}

View File

@@ -10,6 +10,7 @@ import org.springframework.dao.DuplicateKeyException;
import org.springframework.validation.BindException;
import org.springframework.validation.FieldError;
import org.springframework.validation.ObjectError;
import org.springframework.web.HttpRequestMethodNotSupportedException;
import org.springframework.web.bind.MethodArgumentNotValidException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;
@@ -91,6 +92,20 @@ public class GlobalExceptionHandler {
return vo;
}
/**
* 处理此种异常
*
* @param httpRequestMethodNotSupportedException
*/
@ExceptionHandler(value = {HttpRequestMethodNotSupportedException.class})
public void methodNotMatchHandler(HttpRequestMethodNotSupportedException httpRequestMethodNotSupportedException) {
log.debug(
httpRequestMethodNotSupportedException.getMessage()
);
}
/**
* 拦截数据库异常
*