From b8059899ad07bff2b683ccb69673ff4600068dda Mon Sep 17 00:00:00 2001 From: shanjianq <49084314+shanjianq@users.noreply.github.com> Date: Fri, 2 Sep 2022 21:23:21 +0800 Subject: [PATCH] replace fastjson to JSONUtil (#636) Co-authored-by: airoger --- .../pom.xml | 8 +------- .../stream/rabbitmq/example/MessageProduce.java | 4 ++-- ...ServerAdapterSpringCloudStreamRabbitMQApplication.java | 4 ++-- .../stream/rocketmq/example/MessageConsume.java | 6 +++--- .../stream/rocketmq/example/MessageProduce.java | 6 +++--- 5 files changed, 11 insertions(+), 17 deletions(-) diff --git a/hippo4j-example/hippo4j-spring-boot-starter-adapter-spring-cloud-stream-rabbitmq-example/pom.xml b/hippo4j-example/hippo4j-spring-boot-starter-adapter-spring-cloud-stream-rabbitmq-example/pom.xml index 65322198..56d1d1cc 100644 --- a/hippo4j-example/hippo4j-spring-boot-starter-adapter-spring-cloud-stream-rabbitmq-example/pom.xml +++ b/hippo4j-example/hippo4j-spring-boot-starter-adapter-spring-cloud-stream-rabbitmq-example/pom.xml @@ -28,13 +28,7 @@ org.springframework.boot spring-boot-starter-json - - - com.alibaba - fastjson - 1.2.83 - - + org.projectlombok lombok diff --git a/hippo4j-example/hippo4j-spring-boot-starter-adapter-spring-cloud-stream-rabbitmq-example/src/main/java/cn/hippo4j/springboot/starter/adapter/springcloud/stream/rabbitmq/example/MessageProduce.java b/hippo4j-example/hippo4j-spring-boot-starter-adapter-spring-cloud-stream-rabbitmq-example/src/main/java/cn/hippo4j/springboot/starter/adapter/springcloud/stream/rabbitmq/example/MessageProduce.java index 29fb37d7..bf24a379 100644 --- a/hippo4j-example/hippo4j-spring-boot-starter-adapter-spring-cloud-stream-rabbitmq-example/src/main/java/cn/hippo4j/springboot/starter/adapter/springcloud/stream/rabbitmq/example/MessageProduce.java +++ b/hippo4j-example/hippo4j-spring-boot-starter-adapter-spring-cloud-stream-rabbitmq-example/src/main/java/cn/hippo4j/springboot/starter/adapter/springcloud/stream/rabbitmq/example/MessageProduce.java @@ -17,8 +17,8 @@ package cn.hippo4j.springboot.starter.adapter.springcloud.stream.rabbitmq.example; +import cn.hippo4j.common.toolkit.JSONUtil; import cn.hippo4j.example.core.dto.SendMessageDTO; -import com.alibaba.fastjson.JSON; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.cloud.stream.function.StreamBridge; @@ -64,7 +64,7 @@ public class MessageProduce { sendResult, keys, System.currentTimeMillis() - startTime, - JSON.toJSONString(payload)); + JSONUtil.toJSONString(payload)); } } } diff --git a/hippo4j-example/hippo4j-spring-boot-starter-adapter-spring-cloud-stream-rabbitmq-example/src/main/java/cn/hippo4j/springboot/starter/adapter/springcloud/stream/rabbitmq/example/ServerAdapterSpringCloudStreamRabbitMQApplication.java b/hippo4j-example/hippo4j-spring-boot-starter-adapter-spring-cloud-stream-rabbitmq-example/src/main/java/cn/hippo4j/springboot/starter/adapter/springcloud/stream/rabbitmq/example/ServerAdapterSpringCloudStreamRabbitMQApplication.java index 1f0f3c74..ee5fdad6 100644 --- a/hippo4j-example/hippo4j-spring-boot-starter-adapter-spring-cloud-stream-rabbitmq-example/src/main/java/cn/hippo4j/springboot/starter/adapter/springcloud/stream/rabbitmq/example/ServerAdapterSpringCloudStreamRabbitMQApplication.java +++ b/hippo4j-example/hippo4j-spring-boot-starter-adapter-spring-cloud-stream-rabbitmq-example/src/main/java/cn/hippo4j/springboot/starter/adapter/springcloud/stream/rabbitmq/example/ServerAdapterSpringCloudStreamRabbitMQApplication.java @@ -17,8 +17,8 @@ package cn.hippo4j.springboot.starter.adapter.springcloud.stream.rabbitmq.example; +import cn.hippo4j.common.toolkit.JSONUtil; import cn.hippo4j.core.enable.EnableDynamicThreadPool; -import com.alibaba.fastjson.JSON; import lombok.extern.slf4j.Slf4j; import org.springframework.amqp.support.AmqpHeaders; import org.springframework.boot.SpringApplication; @@ -44,7 +44,7 @@ public class ServerAdapterSpringCloudStreamRabbitMQApplication { MessageHeaders headers = message.getHeaders(); log.info("Input current thread name: {} ,{} received from partition {}", Thread.currentThread().getName(), - JSON.toJSONString(message.getPayload()), + JSONUtil.toJSONString(message.getPayload()), headers.get(AmqpHeaders.CONSUMER_QUEUE)); }; } diff --git a/hippo4j-example/hippo4j-spring-boot-starter-adapter-spring-cloud-stream-rocketmq-example/src/main/java/cn/hippo4j/springboot/starter/adapter/springcloud/stream/rocketmq/example/MessageConsume.java b/hippo4j-example/hippo4j-spring-boot-starter-adapter-spring-cloud-stream-rocketmq-example/src/main/java/cn/hippo4j/springboot/starter/adapter/springcloud/stream/rocketmq/example/MessageConsume.java index 6ba5d918..dd96a37e 100644 --- a/hippo4j-example/hippo4j-spring-boot-starter-adapter-spring-cloud-stream-rocketmq-example/src/main/java/cn/hippo4j/springboot/starter/adapter/springcloud/stream/rocketmq/example/MessageConsume.java +++ b/hippo4j-example/hippo4j-spring-boot-starter-adapter-spring-cloud-stream-rocketmq-example/src/main/java/cn/hippo4j/springboot/starter/adapter/springcloud/stream/rocketmq/example/MessageConsume.java @@ -17,8 +17,8 @@ package cn.hippo4j.springboot.starter.adapter.springcloud.stream.rocketmq.example; +import cn.hippo4j.common.toolkit.JSONUtil; import cn.hippo4j.example.core.dto.SendMessageDTO; -import com.alibaba.fastjson.JSON; import lombok.extern.slf4j.Slf4j; import org.springframework.cloud.stream.annotation.StreamListener; import org.springframework.messaging.handler.annotation.Headers; @@ -41,7 +41,7 @@ public class MessageConsume { // ignore } finally { log.info("Keys: {}, Msg id: {}, Execute time: {} ms, Message: {}", headers.get("rocketmq_KEYS"), headers.get("rocketmq_MESSAGE_ID"), System.currentTimeMillis() - startTime, - JSON.toJSONString(message)); + JSONUtil.toJSONString(message)); } log.info("Input current thread name: {}", Thread.currentThread().getName()); } @@ -53,7 +53,7 @@ public class MessageConsume { // ignore } finally { log.info("Keys: {}, Msg id: {}, Execute time: {} ms, Message: {}", headers.get("rocketmq_KEYS"), headers.get("rocketmq_MESSAGE_ID"), System.currentTimeMillis() - startTime, - JSON.toJSONString(message)); + JSONUtil.toJSONString(message)); } log.info("Input2 current thread name: {}", Thread.currentThread().getName()); } diff --git a/hippo4j-example/hippo4j-spring-boot-starter-adapter-spring-cloud-stream-rocketmq-example/src/main/java/cn/hippo4j/springboot/starter/adapter/springcloud/stream/rocketmq/example/MessageProduce.java b/hippo4j-example/hippo4j-spring-boot-starter-adapter-spring-cloud-stream-rocketmq-example/src/main/java/cn/hippo4j/springboot/starter/adapter/springcloud/stream/rocketmq/example/MessageProduce.java index 83370a67..0255a33d 100644 --- a/hippo4j-example/hippo4j-spring-boot-starter-adapter-spring-cloud-stream-rocketmq-example/src/main/java/cn/hippo4j/springboot/starter/adapter/springcloud/stream/rocketmq/example/MessageProduce.java +++ b/hippo4j-example/hippo4j-spring-boot-starter-adapter-spring-cloud-stream-rocketmq-example/src/main/java/cn/hippo4j/springboot/starter/adapter/springcloud/stream/rocketmq/example/MessageProduce.java @@ -17,8 +17,8 @@ package cn.hippo4j.springboot.starter.adapter.springcloud.stream.rocketmq.example; +import cn.hippo4j.common.toolkit.JSONUtil; import cn.hippo4j.example.core.dto.SendMessageDTO; -import com.alibaba.fastjson.JSON; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.apache.rocketmq.common.message.MessageConst; @@ -61,7 +61,7 @@ public class MessageProduce { .uid(keys) .build(); Message message = MessageBuilder - .withPayload(JSON.toJSONString(payload)) + .withPayload(JSONUtil.toJSONString(payload)) .setHeader(MessageConst.PROPERTY_KEYS, keys) .setHeader(MessageConst.PROPERTY_TAGS, tags) .build(); @@ -74,7 +74,7 @@ public class MessageProduce { sendResult, keys, System.currentTimeMillis() - startTime, - JSON.toJSONString(payload)); + JSONUtil.toJSONString(payload)); } } }