[agent] start rabbitmq accomplish the register procedure
This commit is contained in:
@@ -4,6 +4,7 @@ import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import io.wdd.common.beans.rabbitmq.OctopusMessage;
|
||||
import io.wdd.common.handler.MyRuntimeException;
|
||||
import org.springframework.amqp.core.Message;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.io.IOException;
|
||||
@@ -11,11 +12,13 @@ import java.io.IOException;
|
||||
@Component
|
||||
public class MessageUtils {
|
||||
|
||||
@Autowired
|
||||
ObjectMapper objectMapper;
|
||||
|
||||
public static OctopusMessage convert(Message message) {
|
||||
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
|
||||
OctopusMessage octopusMessage;
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
|
||||
try {
|
||||
octopusMessage = objectMapper.readValue(message.getBody(), OctopusMessage.class);
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
package io.wdd.common.utils;
|
||||
|
||||
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
|
||||
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
|
||||
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;
|
||||
import org.springframework.boot.autoconfigure.jackson.Jackson2ObjectMapperBuilderCustomizer;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
|
||||
|
||||
@Configuration
|
||||
public class OctopusObjectMapperConfig {
|
||||
|
||||
public static Jackson2ObjectMapperBuilderCustomizer common() {
|
||||
|
||||
return jacksonObjectMapperBuilder -> {
|
||||
//若POJO对象的属性值为null,序列化时不进行显示
|
||||
//jacksonObjectMapperBuilder.serializationInclusion(JsonInclude.Include.NON_NULL);
|
||||
|
||||
//针对于Date类型,文本格式化
|
||||
jacksonObjectMapperBuilder.simpleDateFormat("yyyy-MM-dd");
|
||||
|
||||
//
|
||||
jacksonObjectMapperBuilder.failOnEmptyBeans(false);
|
||||
jacksonObjectMapperBuilder.failOnUnknownProperties(false);
|
||||
jacksonObjectMapperBuilder.autoDetectFields(true);
|
||||
|
||||
//针对于JDK新时间类。序列化时带有T的问题,自定义格式化字符串
|
||||
JavaTimeModule javaTimeModule = new JavaTimeModule();
|
||||
javaTimeModule.addSerializer(LocalDateTime.class, new LocalDateTimeSerializer(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
|
||||
javaTimeModule.addDeserializer(LocalDateTime.class, new LocalDateTimeDeserializer(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
|
||||
|
||||
jacksonObjectMapperBuilder.modules(javaTimeModule);
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
@@ -13,7 +13,7 @@ import org.springframework.context.annotation.Configuration;
|
||||
import javax.annotation.Resource;
|
||||
import java.text.SimpleDateFormat;
|
||||
|
||||
@Configuration
|
||||
@Deprecated
|
||||
public class OctopusRabbitTemplateConfig {
|
||||
|
||||
@Resource
|
||||
|
||||
Reference in New Issue
Block a user