From 0a612cd01b2ebb7108d719a087a9345f80244eb2 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E9=A9=AC=E5=BA=9C=E5=BC=BA?=
<8569561+fuqiangma@user.noreply.gitee.com>
Date: Fri, 17 Mar 2023 21:50:30 +0800
Subject: [PATCH] =?UTF-8?q?springRetry=E9=87=8D=E8=AF=95?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
springRetry/pom.xml | 158 +++++++++++++++++
.../feign/TLogFeignConsumerRunner.java | 20 +++
.../feign/configuration/MyRedissonConfig.java | 45 +++++
.../feign/configuration/RedisConfig.java | 33 ++++
.../feign/controller/PayController.java | 26 +++
.../feign/service/TestRetryService.java | 35 ++++
.../src/main/resources/application.properties | 21 +++
.../src/main/resources/rateLimiter.lua | 16 ++
.../tlog-example-logback-feign-consumer.iml | 167 ++++++++++++++++++
9 files changed, 521 insertions(+)
create mode 100644 springRetry/pom.xml
create mode 100644 springRetry/src/main/java/com/yomahub/tlog/example/feign/TLogFeignConsumerRunner.java
create mode 100644 springRetry/src/main/java/com/yomahub/tlog/example/feign/configuration/MyRedissonConfig.java
create mode 100644 springRetry/src/main/java/com/yomahub/tlog/example/feign/configuration/RedisConfig.java
create mode 100644 springRetry/src/main/java/com/yomahub/tlog/example/feign/controller/PayController.java
create mode 100644 springRetry/src/main/java/com/yomahub/tlog/example/feign/service/TestRetryService.java
create mode 100644 springRetry/src/main/resources/application.properties
create mode 100644 springRetry/src/main/resources/rateLimiter.lua
create mode 100644 springRetry/tlog-example-logback-feign-consumer.iml
diff --git a/springRetry/pom.xml b/springRetry/pom.xml
new file mode 100644
index 0000000..be5f52c
--- /dev/null
+++ b/springRetry/pom.xml
@@ -0,0 +1,158 @@
+
+
+
+
+
+ 8
+ 8
+ 2.1.8.RELEASE
+ Greenwich.SR3
+ 2.1.0.RELEASE
+ 1.8
+ 1.7.25
+ 2.12.0
+ 1.2.17
+ 1.6.1
+ 2.7.6
+ 2.8.4
+ 4.0.1
+ 3.4.6
+ 0.1
+ 1.0.0
+ 1.5.0
+
+
+ 4.0.0
+ com.yomahub.tlog.example
+ tlog-example-logback-feign-consumer
+ 1.0
+
+
+
+
+ org.springframework.retry
+ spring-retry
+
+
+
+ org.springframework.boot
+ spring-boot-starter-aop
+
+
+
+
+ org.springframework.boot
+ spring-boot-starter-web
+
+
+
+ org.springframework.boot
+ spring-boot-starter-logging
+
+
+
+
+
+ org.springframework.boot
+ spring-boot-starter-log4j2
+
+
+
+
+
+ org.redisson
+ redisson
+ 3.12.0
+
+
+
+
+ com.google.guava
+ guava
+ 30.1-jre
+
+
+
+
+ org.springframework.boot
+ spring-boot-starter-data-redis
+
+
+
+ org.springframework.boot
+ spring-boot-starter-test
+
+
+
+ org.springframework.cloud
+ spring-cloud-starter-openfeign
+
+
+
+
+
+
+
+ com.yomahub
+ tlog-feign-spring-boot-starter
+ ${tlog.version}
+
+
+ com.yomahub
+ tlog-web-spring-boot-starter
+ ${tlog.version}
+
+
+ org.projectlombok
+ lombok
+
+
+ junit
+ junit
+
+
+
+
+
+
+
+ org.springframework.boot
+ spring-boot-dependencies
+ ${spring-boot.version}
+ pom
+ import
+
+
+
+ org.springframework.cloud
+ spring-cloud-dependencies
+ ${spring-cloud.version}
+ pom
+ import
+
+
+ com.alibaba.cloud
+ spring-cloud-alibaba-dependencies
+ ${spring-cloud-alibaba.version}
+ pom
+ import
+
+
+
+
+ log4j
+ log4j
+ ${log4j.version}
+
+
+ org.slf4j
+ slf4j-api
+ ${slf4j.version}
+
+
+
+
+
+
diff --git a/springRetry/src/main/java/com/yomahub/tlog/example/feign/TLogFeignConsumerRunner.java b/springRetry/src/main/java/com/yomahub/tlog/example/feign/TLogFeignConsumerRunner.java
new file mode 100644
index 0000000..b0d5921
--- /dev/null
+++ b/springRetry/src/main/java/com/yomahub/tlog/example/feign/TLogFeignConsumerRunner.java
@@ -0,0 +1,20 @@
+package com.yomahub.tlog.example.feign;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
+import org.springframework.cloud.openfeign.EnableFeignClients;
+import org.springframework.retry.annotation.EnableRetry;
+import org.springframework.scheduling.annotation.EnableAsync;
+
+@SpringBootApplication
+@EnableFeignClients
+@EnableAsync
+@EnableRetry
+public class TLogFeignConsumerRunner {
+
+ public static void main(String[] args) {
+ SpringApplication.run(TLogFeignConsumerRunner.class, args);
+
+ }
+}
diff --git a/springRetry/src/main/java/com/yomahub/tlog/example/feign/configuration/MyRedissonConfig.java b/springRetry/src/main/java/com/yomahub/tlog/example/feign/configuration/MyRedissonConfig.java
new file mode 100644
index 0000000..134f451
--- /dev/null
+++ b/springRetry/src/main/java/com/yomahub/tlog/example/feign/configuration/MyRedissonConfig.java
@@ -0,0 +1,45 @@
+package com.yomahub.tlog.example.feign.configuration;
+
+
+import org.redisson.Redisson;
+import org.redisson.api.RBlockingQueue;
+import org.redisson.api.RDelayedQueue;
+import org.redisson.api.RedissonClient;
+import org.redisson.config.Config;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+import java.io.IOException;
+
+/**
+ * @Description:
+ * @Created: with IntelliJ IDEA.
+ * @author: woniu
+ * @createTime: 2023-03-11 09:39
+ **/
+
+@Configuration
+public class MyRedissonConfig {
+
+ @Bean(destroyMethod = "shutdown")
+ public RedissonClient redisson() throws IOException {
+ Config config = new Config();
+ config.useSingleServer().setAddress("redis://192.168.56.10:6379").setPassword("123456");
+ RedissonClient redissonClient = Redisson.create(config);
+ return redissonClient;
+ }
+
+
+ @Bean
+ public RBlockingQueue blockingQueue(RedissonClient redissonClient) {
+ return redissonClient.getBlockingQueue("TOKEN-RENEWAL");
+ }
+
+ @Bean
+ public RDelayedQueue delayedQueue(RBlockingQueue blockingQueue,
+ RedissonClient redissonClient) {
+ return redissonClient.getDelayedQueue(blockingQueue);
+ }
+}
+
+
diff --git a/springRetry/src/main/java/com/yomahub/tlog/example/feign/configuration/RedisConfig.java b/springRetry/src/main/java/com/yomahub/tlog/example/feign/configuration/RedisConfig.java
new file mode 100644
index 0000000..7e5261a
--- /dev/null
+++ b/springRetry/src/main/java/com/yomahub/tlog/example/feign/configuration/RedisConfig.java
@@ -0,0 +1,33 @@
+package com.yomahub.tlog.example.feign.configuration;
+
+
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.data.redis.connection.RedisConnectionFactory;
+import org.springframework.data.redis.core.RedisTemplate;
+import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer;
+import org.springframework.data.redis.serializer.StringRedisSerializer;
+
+/**
+ * RedisConfig
+ * @date 2023/3/10 21:43
+ */
+@Configuration
+public class RedisConfig {
+
+ @Bean
+ public RedisTemplate redisTemplate(RedisConnectionFactory factory) {
+ RedisTemplate template = new RedisTemplate<>();
+ template.setConnectionFactory(factory);
+ // 使用Jackson2JsonRedisSerializer来序列化和反序列化redis的value值(默认使用JDK的序列化方式)
+ Jackson2JsonRedisSerializer