56
56
import org .springframework .beans .factory .annotation .Autowired ;
57
57
import org .springframework .context .annotation .Bean ;
58
58
import org .springframework .context .annotation .Configuration ;
59
+ import org .springframework .context .event .EventListener ;
59
60
import org .springframework .kafka .annotation .EnableKafka ;
60
61
import org .springframework .kafka .annotation .KafkaListener ;
61
62
import org .springframework .kafka .config .ConcurrentKafkaListenerContainerFactory ;
62
63
import org .springframework .kafka .config .KafkaListenerEndpointRegistry ;
63
64
import org .springframework .kafka .core .ConsumerFactory ;
65
+ import org .springframework .kafka .event .ConsumerPausedEvent ;
64
66
import org .springframework .kafka .listener .ContainerProperties .AckMode ;
65
67
import org .springframework .kafka .test .utils .KafkaTestUtils ;
66
68
import org .springframework .test .annotation .DirtiesContext ;
@@ -114,6 +116,9 @@ public void pausesWithManualAssignment() throws Exception {
114
116
assertThat (this .config .count ).isEqualTo (4 );
115
117
assertThat (this .config .contents ).contains ("foo" , "bar" , "baz" , "qux" );
116
118
verify (this .consumer , never ()).seek (any (), anyLong ());
119
+ assertThat (this .config .eventLatch .await (10 , TimeUnit .SECONDS )).isTrue ();
120
+ assertThat (this .config .event .getPartitions ()).contains (
121
+ new TopicPartition ("foo" , 0 ), new TopicPartition ("foo" , 1 ), new TopicPartition ("foo" , 2 ));
117
122
}
118
123
119
124
@ Configuration
@@ -130,8 +135,12 @@ public static class Config {
130
135
131
136
final CountDownLatch commitLatch = new CountDownLatch (3 );
132
137
138
+ final CountDownLatch eventLatch = new CountDownLatch (1 );
139
+
133
140
int count ;
134
141
142
+ volatile ConsumerPausedEvent event ;
143
+
135
144
@ KafkaListener (id = "id" , groupId = "grp" ,
136
145
topicPartitions = @ org .springframework .kafka .annotation .TopicPartition (topic = "foo" ,
137
146
partitions = "#{'0,1,2'.split(',')}" ))
@@ -228,6 +237,12 @@ ConcurrentKafkaListenerContainerFactory kafkaListenerContainerFactory(KafkaListe
228
237
return factory ;
229
238
}
230
239
240
+ @ EventListener
241
+ public void paused (ConsumerPausedEvent event ) {
242
+ this .event = event ;
243
+ this .eventLatch .countDown ();
244
+ }
245
+
231
246
}
232
247
233
248
}
0 commit comments