Skip to content

Commit b87653f

Browse files
committed
Polishing.
1 parent fbc1b19 commit b87653f

10 files changed

Lines changed: 54 additions & 95 deletions

File tree

redis/listener/src/main/java/example/springdata/redis/listener/Person.java

Lines changed: 0 additions & 69 deletions
This file was deleted.

redis/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818
<modules>
1919
<module>cluster</module>
2020
<module>example</module>
21-
<module>listener</module>
2221
<module>pubsub</module>
22+
<module>pubsub-listener</module>
2323
<module>reactive</module>
2424
<module>repositories</module>
2525
<module>sentinel</module>
File renamed without changes.
Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,11 @@
1010
<relativePath>../pom.xml</relativePath>
1111
</parent>
1212

13-
<artifactId>spring-data-redis-listener</artifactId>
14-
<name>Spring Data Redis - Annotated Listener</name>
15-
<description>Sample project for Spring Data Redis @RedisListener annotation-driven Pub/Sub</description>
13+
<artifactId>spring-data-redis-pubsub-listener</artifactId>
14+
<name>Spring Data Redis - Annotated Pub/Sub Listener</name>
15+
<description>Sample project for annotation-driven Spring Data Redis Pub/Sub
16+
@RedisListener
17+
</description>
1618

1719
<dependencies>
1820

redis/listener/src/main/java/example/springdata/redis/listener/Messages.java renamed to redis/pubsub-listener/src/main/java/example/springdata/redis/listener/Messages.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
/*
2-
* Copyright 2026-present the original author or authors.
2+
* Copyright 2026 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
66
* You may obtain a copy of the License at
77
*
8-
* https://www.apache.org/licenses/LICENSE-2.0
8+
* http://www.apache.org/licenses/LICENSE-2.0
99
*
1010
* Unless required by applicable law or agreed to in writing, software
1111
* distributed under the License is distributed on an "AS IS" BASIS,
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/*
2+
* Copyright 2026 the original author or authors.
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 example.springdata.redis.listener;
17+
18+
/**
19+
* Example domain type for JSON payloads in Redis Pub/Sub messages.
20+
*
21+
* @author Christoph Strobl
22+
*/
23+
public record Person(String firstname, String lastname) {
24+
25+
}

redis/listener/src/main/java/example/springdata/redis/listener/RedisListenerApplication.java renamed to redis/pubsub-listener/src/main/java/example/springdata/redis/listener/RedisListenerApplication.java

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
/*
2-
* Copyright 2026-present the original author or authors.
2+
* Copyright 2026 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
66
* You may obtain a copy of the License at
77
*
8-
* https://www.apache.org/licenses/LICENSE-2.0
8+
* http://www.apache.org/licenses/LICENSE-2.0
99
*
1010
* Unless required by applicable law or agreed to in writing, software
1111
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -62,7 +62,8 @@ static class Listeners {
6262
@RedisListener(topic = "string-channel")
6363
public void processStringMessage(@Payload String data, MessageHeaders headers) {
6464

65-
System.out.printf("received message [%s] from [%s] at [%s].%n", data, headers.get("channel"), headers.getTimestamp());
65+
System.out.printf("received message [%s] from [%s] at [%s].%n", data, headers.get("channel"),
66+
headers.getTimestamp());
6667
messages.capture(data);
6768
}
6869

@@ -77,17 +78,14 @@ public void processPersonMessage(Person person) {
7778
}
7879
}
7980

80-
8181
@Bean
8282
Messages messages() {
8383
return new Messages();
8484
}
8585

8686
/**
87-
* Provide required
88-
* {@link RedisMessageListenerContainer} for annotation-driven endpoints
89-
* {@link Listeners#processStringMessage(String, MessageHeaders)}} &
90-
* {@link Listeners#processPersonMessage(Person)}.
87+
* Provide required {@link RedisMessageListenerContainer} for annotation-driven endpoints
88+
* {@link Listeners#processStringMessage(String, MessageHeaders)}} & {@link Listeners#processPersonMessage(Person)}.
9189
*
9290
* @param connectionFactory must not be {@literal null}.
9391
* @return new instance of {@link RedisListenerApplication}.

redis/listener/src/test/java/example/springdata/redis/listener/AnnotatedRedisListenerIntegrationTests.java renamed to redis/pubsub-listener/src/test/java/example/springdata/redis/listener/AnnotatedRedisListenerIntegrationTests.java

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
/*
2-
* Copyright 2026-present the original author or authors.
2+
* Copyright 2026 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
66
* You may obtain a copy of the License at
77
*
8-
* https://www.apache.org/licenses/LICENSE-2.0
8+
* http://www.apache.org/licenses/LICENSE-2.0
99
*
1010
* Unless required by applicable law or agreed to in writing, software
1111
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -15,11 +15,12 @@
1515
*/
1616
package example.springdata.redis.listener;
1717

18-
import static org.assertj.core.api.Assertions.assertThat;
18+
import static org.assertj.core.api.Assertions.*;
1919

2020
import java.util.concurrent.TimeUnit;
2121

2222
import org.junit.jupiter.api.Test;
23+
2324
import org.springframework.beans.factory.annotation.Autowired;
2425
import org.springframework.boot.test.context.SpringBootTest;
2526
import org.springframework.context.annotation.Import;
@@ -39,8 +40,8 @@ class AnnotatedRedisListenerIntegrationTests {
3940
@Autowired Messages messages;
4041

4142
/**
42-
* Publish a raw String message to the {@literal string-channel} channel and verify that the message
43-
* is received by the {@link RedisListenerApplication.Listeners#processStringMessage(String, MessageHeaders) string listener}.
43+
* Publish a raw String message to the {@literal string-channel} channel and verify that the message is received by
44+
* the {@link RedisListenerApplication.Listeners#processStringMessage(String, MessageHeaders) string listener}.
4445
*/
4546
@Test
4647
void shouldReceiveStringMessage() throws Exception {
@@ -52,8 +53,8 @@ void shouldReceiveStringMessage() throws Exception {
5253
}
5354

5455
/**
55-
* Publish a JSON String message to the {@literal person-channel} channel and verify that the payload is converted
56-
* and processed by the {@link RedisListenerApplication.Listeners#processPersonMessage(Person) person listener}.
56+
* Publish a JSON String message to the {@literal person-channel} channel and verify that the payload is converted and
57+
* processed by the {@link RedisListenerApplication.Listeners#processPersonMessage(Person) person listener}.
5758
*/
5859
@Test
5960
void shouldReceiveJsonPersonMessage() throws Exception {
@@ -63,7 +64,7 @@ void shouldReceiveJsonPersonMessage() throws Exception {
6364

6465
Person received = messages.capturedPojos().poll(5, TimeUnit.SECONDS);
6566
assertThat(received).isNotNull();
66-
assertThat(received.getFirstname()).isEqualTo("Homer");
67-
assertThat(received.getLastname()).isEqualTo("Simpson");
67+
assertThat(received.firstname()).isEqualTo("Homer");
68+
assertThat(received.lastname()).isEqualTo("Simpson");
6869
}
6970
}

redis/listener/src/test/java/example/springdata/redis/listener/RedisTestConfiguration.java renamed to redis/pubsub-listener/src/test/java/example/springdata/redis/listener/RedisTestConfiguration.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
/*
2-
* Copyright 2026-present the original author or authors.
2+
* Copyright 2026 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
66
* You may obtain a copy of the License at
77
*
8-
* https://www.apache.org/licenses/LICENSE-2.0
8+
* http://www.apache.org/licenses/LICENSE-2.0
99
*
1010
* Unless required by applicable law or agreed to in writing, software
1111
* distributed under the License is distributed on an "AS IS" BASIS,
@@ -15,12 +15,14 @@
1515
*/
1616
package example.springdata.redis.listener;
1717

18-
import com.redis.testcontainers.RedisContainer;
1918
import org.springframework.boot.test.context.TestConfiguration;
2019
import org.springframework.boot.testcontainers.service.connection.ServiceConnection;
2120
import org.springframework.context.annotation.Bean;
21+
2222
import org.testcontainers.utility.DockerImageName;
2323

24+
import com.redis.testcontainers.RedisContainer;
25+
2426
/**
2527
* Test configuration providing a Redis instance via Testcontainers.
2628
*

redis/listener/src/test/resources/application.properties renamed to redis/pubsub-listener/src/test/resources/application.properties

File renamed without changes.

0 commit comments

Comments
 (0)