50
50
*
51
51
* @author Mark Paluch
52
52
* @author Christoph Strobl
53
+ * @author Su Ko
53
54
* @since 2.2
54
55
*/
55
56
class DefaultStreamMessageListenerContainer <K , V extends Record <K , ?>> implements StreamMessageListenerContainer <K , V > {
@@ -67,6 +68,9 @@ class DefaultStreamMessageListenerContainer<K, V extends Record<K, ?>> implement
67
68
68
69
private boolean running = false ;
69
70
71
+ private int phase = Integer .MAX_VALUE ;
72
+ private boolean autoStartup = false ;
73
+
70
74
/**
71
75
* Create a new {@link DefaultStreamMessageListenerContainer}.
72
76
*
@@ -123,9 +127,21 @@ private RedisTemplate<K, V> createRedisTemplate(RedisConnectionFactory connectio
123
127
124
128
@ Override
125
129
public boolean isAutoStartup () {
126
- return false ;
130
+ return this . autoStartup ;
127
131
}
128
132
133
+ /**
134
+ * Configure if this Lifecycle connection factory should get started automatically by the container at the time that
135
+ * the containing ApplicationContext gets refreshed.
136
+ * The default is {@code false}.
137
+ *
138
+ * @see org.springframework.context.SmartLifecycle#isAutoStartup()
139
+ * @since 4.0.0
140
+ */
141
+ public void setAutoStartup (boolean autoStartup ) {
142
+ this .autoStartup = autoStartup ;
143
+ }
144
+
129
145
@ Override
130
146
public void stop (Runnable callback ) {
131
147
@@ -177,9 +193,21 @@ public boolean isRunning() {
177
193
178
194
@ Override
179
195
public int getPhase () {
180
- return Integer . MAX_VALUE ;
196
+ return this . phase ;
181
197
}
182
198
199
+ /**
200
+ * Specify the lifecycle phase for this container.
201
+ * Lower values start earlier and stop later.
202
+ * The default is {@code Integer.MAX_VALUE}.
203
+ *
204
+ * @see org.springframework.context.SmartLifecycle#getPhase()
205
+ * @since 4.0.0
206
+ */
207
+ public void setPhase (int phase ) {
208
+ this .phase = phase ;
209
+ }
210
+
183
211
@ Override
184
212
public Subscription register (StreamReadRequest <K > streamRequest , StreamListener <K , V > listener ) {
185
213
0 commit comments