Skip to content

Commit fa56527

Browse files
committed
Polishing.
- Remove comments from docs (details can be found in the javadocs and reduces maintenance - Remove Lettuce specific ITs added in previous commit (already covered in base test) - Added Javadoc to setAutoStartup Original Pull Request #3293 Signed-off-by: Chris Bono <chris.bono@broadcom.com>
1 parent a53929c commit fa56527

File tree

4 files changed

+22
-36
lines changed

4 files changed

+22
-36
lines changed

src/main/antora/modules/ROOT/pages/redis/redis-streams.adoc

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,6 @@ StreamMessageListenerContainer<String, MapRecord<String, String, String>> contai
128128
Subscription subscription = container.receive(StreamOffset.fromStart("my-stream"), streamListener);
129129
----
130130

131-
The default value for `autoStartup` is `true`.
132-
133131
Please refer to the Javadoc of the various message listener containers for a full description of the features supported by each implementation.
134132

135133
[[reactive-streamreceiver]]

src/main/java/org/springframework/data/redis/stream/DefaultStreamMessageListenerContainer.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
* @author Mark Paluch
5252
* @author Christoph Strobl
5353
* @author Su Ko
54+
* @author Yumin Jung
5455
* @since 2.2
5556
*/
5657
class DefaultStreamMessageListenerContainer<K, V extends Record<K, ?>> implements StreamMessageListenerContainer<K, V> {
@@ -192,6 +193,13 @@ public boolean isAutoStartup() {
192193
return this.autoStartup;
193194
}
194195

196+
/**
197+
* Configure if this listener container should get started automatically at the time that the containing
198+
* {@code ApplicationContext} gets refreshed. The default is {@code true}.
199+
*
200+
* @see org.springframework.context.SmartLifecycle#isAutoStartup()
201+
* @since 4.1
202+
*/
195203
public void setAutoStartup(boolean autoStartup) {
196204
this.autoStartup = autoStartup;
197205
}

src/test/java/org/springframework/data/redis/stream/AbstractStreamMessageListenerContainerIntegrationTests.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,7 @@ void containerRestartShouldRestartSubscription() throws InterruptedException {
386386

387387
@Test // GH-3208
388388
void defaultPhaseShouldBeMaxValue() {
389+
389390
StreamMessageListenerContainer<String, MapRecord<String, String, String>> container = StreamMessageListenerContainer
390391
.create(connectionFactory, containerOptions);
391392

@@ -394,6 +395,7 @@ void defaultPhaseShouldBeMaxValue() {
394395

395396
@Test // GH-3208
396397
void shouldApplyConfiguredPhase() {
398+
397399
StreamMessageListenerContainerOptions<String, MapRecord<String, String, String>> options = StreamMessageListenerContainerOptions
398400
.builder().phase(3208).build();
399401
StreamMessageListenerContainer<String, MapRecord<String, String, String>> container = StreamMessageListenerContainer
@@ -413,6 +415,7 @@ void defaultAutoStartupShouldBeTrue() {
413415

414416
@Test // GH-3208
415417
void shouldApplyConfiguredAutoStartup() {
418+
416419
StreamMessageListenerContainerOptions<String, MapRecord<String, String, String>> options = StreamMessageListenerContainerOptions
417420
.builder().autoStartup(true).build();
418421
StreamMessageListenerContainer<String, MapRecord<String, String, String>> container = StreamMessageListenerContainer
@@ -421,6 +424,17 @@ void shouldApplyConfiguredAutoStartup() {
421424
assertThat(container.isAutoStartup()).isEqualTo(true);
422425
}
423426

427+
@Test // GH-2568
428+
void shouldRetainAutoStartupSetting() {
429+
430+
DefaultStreamMessageListenerContainer container = new DefaultStreamMessageListenerContainer(connectionFactory,
431+
StreamMessageListenerContainerOptions.builder().autoStartup(false).build());
432+
433+
assertThat(container.isAutoStartup()).isFalse();
434+
container.setAutoStartup(true);
435+
assertThat(container.isAutoStartup()).isTrue();
436+
}
437+
424438
private static void cancelAwait(Subscription subscription) {
425439

426440
subscription.cancel();

src/test/java/org/springframework/data/redis/stream/LettuceStreamMessageListenerContainerIntegrationTests.java

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,11 @@
1515
*/
1616
package org.springframework.data.redis.stream;
1717

18-
import static org.assertj.core.api.Assertions.assertThat;
19-
20-
import org.junit.jupiter.api.Test;
2118
import org.junit.jupiter.api.TestInstance;
2219
import org.junit.jupiter.api.extension.ExtendWith;
2320

2421
import org.springframework.data.redis.connection.RedisConnectionFactory;
2522
import org.springframework.data.redis.connection.lettuce.extension.LettuceConnectionFactoryExtension;
26-
import org.springframework.data.redis.connection.stream.MapRecord;
2723
import org.springframework.data.redis.test.condition.EnabledOnCommand;
2824

2925
/**
@@ -38,38 +34,8 @@
3834
public class LettuceStreamMessageListenerContainerIntegrationTests
3935
extends AbstractStreamMessageListenerContainerIntegrationTests {
4036

41-
private final RedisConnectionFactory connectionFactory;
42-
4337
public LettuceStreamMessageListenerContainerIntegrationTests(RedisConnectionFactory connectionFactory) {
4438
super(connectionFactory);
45-
this.connectionFactory = connectionFactory;
46-
}
47-
48-
@Test // GH-2568
49-
void shouldHaveAutoStartupEnabledByDefault() {
50-
51-
StreamMessageListenerContainer.StreamMessageListenerContainerOptions<String, MapRecord<String, String, String>> options =
52-
StreamMessageListenerContainer.StreamMessageListenerContainerOptions.builder().build();
53-
54-
StreamMessageListenerContainer<String, MapRecord<String, String, String>> container =
55-
StreamMessageListenerContainer.create(connectionFactory, options);
56-
57-
assertThat(container.isAutoStartup()).isTrue();
5839
}
5940

60-
@Test // GH-2568
61-
void shouldAllowConfiguringAutoStartup() {
62-
63-
StreamMessageListenerContainer.StreamMessageListenerContainerOptions<String, MapRecord<String, String, String>> options =
64-
StreamMessageListenerContainer.StreamMessageListenerContainerOptions.builder().build();
65-
66-
DefaultStreamMessageListenerContainer<String, MapRecord<String, String, String>> container =
67-
new DefaultStreamMessageListenerContainer<>(connectionFactory, options);
68-
69-
container.setAutoStartup(false);
70-
assertThat(container.isAutoStartup()).isFalse();
71-
72-
container.setAutoStartup(true);
73-
assertThat(container.isAutoStartup()).isTrue();
74-
}
7541
}

0 commit comments

Comments
 (0)