diff --git a/README.md b/README.md index 502bb3b..966412a 100644 --- a/README.md +++ b/README.md @@ -3,4 +3,12 @@ > loki框架测试 - [loki-simple-test](loki-simple-test) - 基于spring 3.2 简单测试 \ No newline at end of file + 基于spring 3.2 简单测试 +- [loki-kafka-test](loki-kafka-test) + kafka测试,支持kafka3.x +- [loki-redis-test](loki-redis-test) + redis测试,支持redis5以上版本 +- [loki-rocketmq-remoting-test](loki-rocketmq-remoting-test) + rocketmq-remoting协议测试,支持rocketmq 4.x 、5.x +- [loki-rocketmq-test](loki-rocketmq-test) + rocketmq-grpc协议测试,支持rocketmq 5.x diff --git a/loki-kafka-test/pom.xml b/loki-kafka-test/pom.xml index bd0424c..6b89b62 100644 --- a/loki-kafka-test/pom.xml +++ b/loki-kafka-test/pom.xml @@ -9,7 +9,7 @@ io.github.guoshiqiufeng loki-kafka-test - 0.0.1-SNAPSHOT + loki-kafka-test loki-kafka-test diff --git a/loki-kafka-test/src/main/java/io/github/guoshiqiufeng/lokitest/controller/ClientController.java b/loki-kafka-test/src/main/java/io/github/guoshiqiufeng/lokitest/controller/ClientController.java new file mode 100644 index 0000000..cfdee86 --- /dev/null +++ b/loki-kafka-test/src/main/java/io/github/guoshiqiufeng/lokitest/controller/ClientController.java @@ -0,0 +1,38 @@ +package io.github.guoshiqiufeng.lokitest.controller; + +import cn.hutool.core.util.IdUtil; +import cn.hutool.json.JSONUtil; +import io.github.guoshiqiufeng.loki.support.core.ProducerRecord; +import io.github.guoshiqiufeng.loki.support.core.ProducerResult; +import io.github.guoshiqiufeng.loki.support.kafka.KafkaClient; +import jakarta.annotation.Resource; +import lombok.extern.slf4j.Slf4j; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import java.util.concurrent.ExecutionException; + +/** + * @author yanghq + * @version 1.0 + * @since 2024/1/24 16:54 + */ +@Slf4j +@RequestMapping("/client") +@RestController +public class ClientController { + + @Resource + private KafkaClient kafkaClient; + + @GetMapping("send") + public String send() throws ExecutionException, InterruptedException { + ProducerRecord record = new ProducerRecord(); + record.setTopic("loki"); + record.setMessage(IdUtil.getSnowflakeNextIdStr()); + ProducerResult result = kafkaClient.sendAsync(record).get(); + log.debug("send result:{}", JSONUtil.toJsonStr(result)); + return "success"; + } +} diff --git a/loki-redis-test/pom.xml b/loki-redis-test/pom.xml index 4fc5d0b..74d3178 100644 --- a/loki-redis-test/pom.xml +++ b/loki-redis-test/pom.xml @@ -9,7 +9,7 @@ io.github.guoshiqiufeng loki-redis-test - 0.0.1-SNAPSHOT + loki-redis-test loki-redis-test diff --git a/loki-redis-test/src/main/java/io/github/guoshiqiufeng/lokitest/controller/ClientController.java b/loki-redis-test/src/main/java/io/github/guoshiqiufeng/lokitest/controller/ClientController.java new file mode 100644 index 0000000..01919b9 --- /dev/null +++ b/loki-redis-test/src/main/java/io/github/guoshiqiufeng/lokitest/controller/ClientController.java @@ -0,0 +1,38 @@ +package io.github.guoshiqiufeng.lokitest.controller; + +import cn.hutool.core.util.IdUtil; +import cn.hutool.json.JSONUtil; +import io.github.guoshiqiufeng.loki.support.core.LokiClient; +import io.github.guoshiqiufeng.loki.support.core.ProducerRecord; +import io.github.guoshiqiufeng.loki.support.core.ProducerResult; +import jakarta.annotation.Resource; +import lombok.extern.slf4j.Slf4j; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import java.util.concurrent.ExecutionException; + +/** + * @author yanghq + * @version 1.0 + * @since 2024/1/24 16:54 + */ +@Slf4j +@RequestMapping("/client") +@RestController +public class ClientController { + + @Resource + private LokiClient lokiClient; + + @GetMapping("send") + public String send() throws ExecutionException, InterruptedException { + ProducerRecord record = new ProducerRecord(); + record.setTopic("loki"); + record.setMessage(IdUtil.getSnowflakeNextIdStr()); + ProducerResult result = lokiClient.sendAsync(record).get(); + log.debug("send result:{}", JSONUtil.toJsonStr(result)); + return "success"; + } +} diff --git a/loki-rocketmq-remoting-test/pom.xml b/loki-rocketmq-remoting-test/pom.xml index 0d43f15..d709d77 100644 --- a/loki-rocketmq-remoting-test/pom.xml +++ b/loki-rocketmq-remoting-test/pom.xml @@ -9,7 +9,7 @@ io.github.guoshiqiufeng loki-rocketmq-remoting-test - 0.0.1-SNAPSHOT + loki-rocketmq-remoting-test loki-rocketmq-remoting-test diff --git a/loki-rocketmq-remoting-test/src/main/java/io/github/guoshiqiufeng/lokitest/controller/ClientController.java b/loki-rocketmq-remoting-test/src/main/java/io/github/guoshiqiufeng/lokitest/controller/ClientController.java new file mode 100644 index 0000000..122256f --- /dev/null +++ b/loki-rocketmq-remoting-test/src/main/java/io/github/guoshiqiufeng/lokitest/controller/ClientController.java @@ -0,0 +1,38 @@ +package io.github.guoshiqiufeng.lokitest.controller; + +import cn.hutool.core.util.IdUtil; +import cn.hutool.json.JSONUtil; +import io.github.guoshiqiufeng.loki.support.core.ProducerRecord; +import io.github.guoshiqiufeng.loki.support.core.ProducerResult; +import io.github.guoshiqiufeng.loki.support.rocketmq.remoting.RocketRemotingClient; +import jakarta.annotation.Resource; +import lombok.extern.slf4j.Slf4j; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import java.util.concurrent.ExecutionException; + +/** + * @author yanghq + * @version 1.0 + * @since 2024/1/24 16:54 + */ +@Slf4j +@RequestMapping("/client") +@RestController +public class ClientController { + + @Resource + private RocketRemotingClient rocketRemotingClient; + + @GetMapping("send") + public String send() throws ExecutionException, InterruptedException { + ProducerRecord record = new ProducerRecord(); + record.setTopic("loki"); + record.setMessage(IdUtil.getSnowflakeNextIdStr()); + ProducerResult result = rocketRemotingClient.sendAsync(record).get(); + log.debug("send result:{}", JSONUtil.toJsonStr(result)); + return "success"; + } +} diff --git a/loki-rocketmq-test/pom.xml b/loki-rocketmq-test/pom.xml index 39e4c3d..34d2232 100644 --- a/loki-rocketmq-test/pom.xml +++ b/loki-rocketmq-test/pom.xml @@ -9,7 +9,7 @@ io.github.guoshiqiufeng loki-rocketmq-test - 0.0.1-SNAPSHOT + loki-rocketmq-test loki-rocketmq-test diff --git a/loki-rocketmq-test/src/main/java/io/github/guoshiqiufeng/lokitest/controller/ClientController.java b/loki-rocketmq-test/src/main/java/io/github/guoshiqiufeng/lokitest/controller/ClientController.java new file mode 100644 index 0000000..456e0e2 --- /dev/null +++ b/loki-rocketmq-test/src/main/java/io/github/guoshiqiufeng/lokitest/controller/ClientController.java @@ -0,0 +1,38 @@ +package io.github.guoshiqiufeng.lokitest.controller; + +import cn.hutool.core.util.IdUtil; +import cn.hutool.json.JSONUtil; +import io.github.guoshiqiufeng.loki.support.core.ProducerRecord; +import io.github.guoshiqiufeng.loki.support.core.ProducerResult; +import io.github.guoshiqiufeng.loki.support.rocketmq.RocketClient; +import jakarta.annotation.Resource; +import lombok.extern.slf4j.Slf4j; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import java.util.concurrent.ExecutionException; + +/** + * @author yanghq + * @version 1.0 + * @since 2024/1/24 16:54 + */ +@Slf4j +@RequestMapping("/client") +@RestController +public class ClientController { + + @Resource + private RocketClient rocketClient; + + @GetMapping("send") + public String send() throws ExecutionException, InterruptedException { + ProducerRecord record = new ProducerRecord(); + record.setTopic("loki"); + record.setMessage(IdUtil.getSnowflakeNextIdStr()); + ProducerResult result = rocketClient.sendAsync(record).get(); + log.debug("send result:{}", JSONUtil.toJsonStr(result)); + return "success"; + } +} diff --git a/loki-rocketmq-test/src/main/java/io/github/guoshiqiufeng/lokitest/controller/TestController.java b/loki-rocketmq-test/src/main/java/io/github/guoshiqiufeng/lokitest/controller/TestController.java index 125a02b..3bed8a8 100644 --- a/loki-rocketmq-test/src/main/java/io/github/guoshiqiufeng/lokitest/controller/TestController.java +++ b/loki-rocketmq-test/src/main/java/io/github/guoshiqiufeng/lokitest/controller/TestController.java @@ -8,6 +8,7 @@ import com.fasterxml.jackson.databind.SerializationFeature; import com.fasterxml.jackson.databind.jsontype.impl.LaissezFaireSubTypeValidator; import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; +import io.github.guoshiqiufeng.loki.support.rocketmq.RocketClient; import io.github.guoshiqiufeng.lokitest.entity.TestEntity; import io.github.guoshiqiufeng.lokitest.mapper.TestMapper; import jakarta.annotation.Resource; diff --git a/loki-simple-test/pom.xml b/loki-simple-test/pom.xml index babf0c9..2316244 100644 --- a/loki-simple-test/pom.xml +++ b/loki-simple-test/pom.xml @@ -9,7 +9,7 @@ io.github.guoshiqiufeng loki-simple-test - 0.0.1-SNAPSHOT + loki-test loki-test diff --git a/loki-simple-test/src/main/java/io/github/guoshiqiufeng/lokitest/controller/ClientController.java b/loki-simple-test/src/main/java/io/github/guoshiqiufeng/lokitest/controller/ClientController.java new file mode 100644 index 0000000..cbfec1d --- /dev/null +++ b/loki-simple-test/src/main/java/io/github/guoshiqiufeng/lokitest/controller/ClientController.java @@ -0,0 +1,41 @@ +package io.github.guoshiqiufeng.lokitest.controller; + +import cn.hutool.core.util.IdUtil; +import com.alibaba.fastjson.JSON; +import io.github.guoshiqiufeng.loki.support.core.LokiClient; +import io.github.guoshiqiufeng.loki.support.core.ProducerRecord; +import io.github.guoshiqiufeng.loki.support.core.ProducerResult; +import io.github.guoshiqiufeng.loki.support.kafka.KafkaClient; +import io.github.guoshiqiufeng.loki.support.redis.RedisClient; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import jakarta.annotation.Resource; +import java.util.concurrent.ExecutionException; + +/** + * @author yanghq + * @version 1.0 + * @since 2024/1/24 16:54 + */ +@Slf4j +@RequestMapping("/client") +@RestController +public class ClientController { + + @Resource + private RedisClient redisClient; + + @GetMapping("send") + public String send() throws ExecutionException, InterruptedException { + ProducerRecord record = new ProducerRecord(); + record.setTopic("loki"); + record.setMessage(IdUtil.getSnowflakeNextIdStr()); + ProducerResult result = redisClient.sendAsync(record).get(); + log.debug("send result:{}", JSON.toJSONString(result)); + return "success"; + } +} diff --git a/loki-simple-test/src/main/resources/application.yml b/loki-simple-test/src/main/resources/application.yml index 4c2fdbd..ad3d379 100644 --- a/loki-simple-test/src/main/resources/application.yml +++ b/loki-simple-test/src/main/resources/application.yml @@ -17,11 +17,12 @@ loki: mq-config: mq-type: redis address: 127.0.0.1:6379 - + auth: true + password: 123456 # mq-type: ROCKET_MQ # address: 127.0.0.1:8081 # auth: false # username: username # password: password # connect-timeout: 300 -# max-attempts: 5 \ No newline at end of file +# max-attempts: 5 diff --git a/pom.xml b/pom.xml index 3d9dc0a..45d7c54 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ org.springframework.boot spring-boot-starter-parent - 3.2.0 + 3.2.2 @@ -19,7 +19,7 @@ 17 - 0.7.0 + 0.8.1