Skip to content

Commit 290a29c

Browse files
Merge pull request #7 from guoshiqiufeng/dev
0.4.0
2 parents 280d11e + 448507d commit 290a29c

File tree

18 files changed

+466
-14
lines changed

18 files changed

+466
-14
lines changed

README-zh.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ https://guoshiqiufeng.github.io/spring-cloud-stream-redis/
1616

1717
### 开发框架
1818

19-
- Spring Cloud Stream 4.1.3
20-
- Spring Boot
19+
- Spring Cloud Stream 4
20+
- Spring Boot 3
2121

2222
### 功能
2323

@@ -39,7 +39,7 @@ https://guoshiqiufeng.github.io/spring-cloud-stream-redis/
3939
<dependency>
4040
<groupId>io.github.guoshiqiufeng.cloud</groupId>
4141
<artifactId>spring-cloud-stream-dependencies</artifactId>
42-
<version>0.3.0</version>
42+
<version>0.4.0</version>
4343
<type>import</type>
4444
</dependency>
4545
</dependencies>

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ https://guoshiqiufeng.github.io/spring-cloud-stream-redis/en/
1717

1818
### Development Framework
1919

20-
- Spring Cloud Stream 4.1.3
21-
- Spring Boot
20+
- Spring Cloud Stream 4
21+
- Spring Boot 3
2222

2323
### Features
2424

@@ -41,7 +41,7 @@ https://guoshiqiufeng.github.io/spring-cloud-stream-redis/en/
4141
<dependency>
4242
<groupId>io.github.guoshiqiufeng.cloud</groupId>
4343
<artifactId>spring-cloud-stream-dependencies</artifactId>
44-
<version>0.3.0</version>
44+
<version>0.4.0</version>
4545
<type>import</type>
4646
</dependency>
4747
</dependencies>

binders/spring-cloud-stream-binder-redis-core/src/main/java/io/github/guoshiqiufeng/cloud/stream/binder/redis/support/converter/MessagingMessageConverter.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1+
/*
2+
* Copyright (c) 2023-2024, fubluesky ([email protected])
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
116
package io.github.guoshiqiufeng.cloud.stream.binder.redis.support.converter;
217

318
import org.jetbrains.annotations.NotNull;

binders/spring-cloud-stream-binder-redis-core/src/test/java/io/github/guoshiqiufeng/cloud/stream/binder/redis/properties/RedisBinderConfigurationPropertiesTest.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
package io.github.guoshiqiufeng.cloud.stream.binder.redis.properties;
1717

1818
import org.junit.jupiter.api.Test;
19+
import org.springframework.boot.autoconfigure.data.redis.RedisProperties;
1920

2021
import static org.junit.jupiter.api.Assertions.assertEquals;
2122

@@ -30,19 +31,19 @@ public class RedisBinderConfigurationPropertiesTest {
3031
void testDefaultProperties() {
3132
RedisProperties redisProperties = new RedisProperties();
3233
RedisBinderConfigurationProperties properties = new RedisBinderConfigurationProperties(redisProperties);
33-
34+
3435
assertEquals("localhost", properties.getConfiguration().getHost());
3536
assertEquals(6379, properties.getConfiguration().getPort());
3637
}
3738

38-
@Test
39+
@Test
3940
void testCustomProperties() {
4041
RedisProperties redisProperties = new RedisProperties();
4142
redisProperties.setHost("redis.example.com");
4243
redisProperties.setPort(6380);
43-
44+
4445
RedisBinderConfigurationProperties properties = new RedisBinderConfigurationProperties(redisProperties);
45-
46+
4647
assertEquals("redis.example.com", properties.getConfiguration().getHost());
4748
assertEquals(6380, properties.getConfiguration().getPort());
4849
}

binders/spring-cloud-stream-binder-redis/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
dependencies {
22
api project(":binders:spring-cloud-stream-binder-redis-core")
33

4-
annotationProcessor "org.springframework.boot:spring-boot-starter-actuator"
4+
implementation "org.springframework.boot:spring-boot-starter-actuator"
55
annotationProcessor "org.springframework.boot:spring-boot-configuration-processor"
66
annotationProcessor "org.springframework.boot:spring-boot-autoconfigure"
77

binders/spring-cloud-stream-binder-redis/src/main/java/io/github/guoshiqiufeng/cloud/stream/binder/redis/config/RedisBinderConfiguration.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
import org.springframework.cloud.stream.config.ProducerMessageHandlerCustomizer;
3232
import org.springframework.context.annotation.Bean;
3333
import org.springframework.context.annotation.Configuration;
34+
import org.springframework.context.annotation.Import;
3435
import org.springframework.data.redis.listener.RedisMessageListenerContainer;
3536
import org.springframework.integration.redis.inbound.RedisStoreMessageSource;
3637

@@ -41,7 +42,7 @@
4142
*/
4243
@Configuration(proxyBeanMethods = false)
4344
@ConditionalOnMissingBean(Binder.class)
44-
// @Import({RedisBinderHealthIndicatorConfiguration.class})
45+
@Import({RedisBinderHealthIndicatorConfiguration.class})
4546
@EnableConfigurationProperties({RedisProperties.class, RedisExtendedBindingProperties.class})
4647
public class RedisBinderConfiguration {
4748

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
/*
2+
* Copyright (c) 2023-2024, fubluesky ([email protected])
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package io.github.guoshiqiufeng.cloud.stream.binder.redis.config;
17+
18+
import io.github.guoshiqiufeng.cloud.stream.binder.redis.health.RedisBinderHealth;
19+
import io.github.guoshiqiufeng.cloud.stream.binder.redis.health.RedisBinderHealthIndicator;
20+
import io.github.guoshiqiufeng.cloud.stream.binder.redis.properties.RedisBinderConfigurationProperties;
21+
import io.github.guoshiqiufeng.cloud.stream.binder.redis.utils.RedisConnectionFactoryUtil;
22+
import org.springframework.boot.actuate.autoconfigure.health.ConditionalOnEnabledHealthIndicator;
23+
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
24+
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
25+
import org.springframework.context.annotation.Bean;
26+
import org.springframework.context.annotation.Configuration;
27+
import org.springframework.data.redis.connection.RedisConnectionFactory;
28+
29+
/**
30+
* Configuration for Redis binder health indicators.
31+
*
32+
* @author yanghq
33+
* @version 1.0
34+
* @since 2024/11/17 10:55
35+
*/
36+
@Configuration(proxyBeanMethods = false)
37+
@ConditionalOnClass(name = "org.springframework.boot.actuate.health.HealthIndicator")
38+
@ConditionalOnEnabledHealthIndicator("binders")
39+
@ConditionalOnMissingBean(RedisBinderHealth.class)
40+
public class RedisBinderHealthIndicatorConfiguration {
41+
42+
@Bean
43+
public RedisBinderHealthIndicator redisBinderHealthIndicator(RedisBinderConfigurationProperties configurationProperties) {
44+
RedisConnectionFactory connectionFactory = RedisConnectionFactoryUtil.getRedisConnectionFactory(
45+
configurationProperties.getConfiguration());
46+
return new RedisBinderHealthIndicator(connectionFactory);
47+
}
48+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package io.github.guoshiqiufeng.cloud.stream.binder.redis.health;
2+
3+
import org.springframework.boot.actuate.health.HealthIndicator;
4+
5+
/**
6+
* Health indicator for Redis binder.
7+
* @author yanghq
8+
* @version 1.0
9+
* @since 2024/11/18 15:07
10+
*/
11+
public interface RedisBinderHealth extends HealthIndicator {
12+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/*
2+
* Copyright (c) 2023-2024, fubluesky ([email protected])
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package io.github.guoshiqiufeng.cloud.stream.binder.redis.health;
17+
18+
import org.springframework.boot.actuate.data.redis.RedisHealthIndicator;
19+
import org.springframework.data.redis.connection.RedisConnectionFactory;
20+
21+
/**
22+
* Health indicator for Redis binder.
23+
*
24+
* @author yanghq
25+
* @version 1.0
26+
* @since 2024/11/17 10:00
27+
*/
28+
public class RedisBinderHealthIndicator extends RedisHealthIndicator {
29+
30+
public RedisBinderHealthIndicator(RedisConnectionFactory connectionFactory) {
31+
super(connectionFactory);
32+
}
33+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/*
2+
* Copyright (c) 2023-2024, fubluesky ([email protected])
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package io.github.guoshiqiufeng.cloud.stream.binder.redis.health;
17+
18+
import io.github.guoshiqiufeng.cloud.stream.binder.redis.RedisContainerTest;
19+
import org.junit.jupiter.api.Test;
20+
import org.springframework.boot.actuate.health.Health;
21+
import org.springframework.boot.actuate.health.Status;
22+
import org.springframework.data.redis.connection.RedisConnectionFactory;
23+
24+
import static org.assertj.core.api.Assertions.assertThat;
25+
26+
/**
27+
* @author yanghq
28+
* @version 1.0
29+
* @since 2024/11/17 17:04
30+
*/
31+
class RedisBinderHealthIndicatorIntegrationTest implements RedisContainerTest {
32+
33+
@Test
34+
void shouldReportHealthWithRealRedis() {
35+
RedisConnectionFactory connectionFactory = RedisContainerTest.connectionFactory();
36+
37+
RedisBinderHealthIndicator healthIndicator = new RedisBinderHealthIndicator(connectionFactory);
38+
Health health = healthIndicator.health();
39+
40+
assertThat(health.getStatus()).isEqualTo(Status.UP);
41+
assertThat(health.getDetails())
42+
.containsKey("version")
43+
.containsKey("mode");
44+
}
45+
}

0 commit comments

Comments
 (0)