5656import org .springframework .beans .factory .annotation .Autowired ;
5757import org .springframework .context .annotation .Bean ;
5858import org .springframework .context .annotation .Configuration ;
59+ import org .springframework .context .event .EventListener ;
5960import org .springframework .kafka .annotation .EnableKafka ;
6061import org .springframework .kafka .annotation .KafkaListener ;
6162import org .springframework .kafka .config .ConcurrentKafkaListenerContainerFactory ;
6263import org .springframework .kafka .config .KafkaListenerEndpointRegistry ;
6364import org .springframework .kafka .core .ConsumerFactory ;
65+ import org .springframework .kafka .event .ConsumerPausedEvent ;
6466import org .springframework .kafka .listener .ContainerProperties .AckMode ;
6567import org .springframework .kafka .test .utils .KafkaTestUtils ;
6668import org .springframework .test .annotation .DirtiesContext ;
@@ -114,6 +116,9 @@ public void pausesWithManualAssignment() throws Exception {
114116 assertThat (this .config .count ).isEqualTo (4 );
115117 assertThat (this .config .contents ).contains ("foo" , "bar" , "baz" , "qux" );
116118 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 ));
117122 }
118123
119124 @ Configuration
@@ -130,8 +135,12 @@ public static class Config {
130135
131136 final CountDownLatch commitLatch = new CountDownLatch (3 );
132137
138+ final CountDownLatch eventLatch = new CountDownLatch (1 );
139+
133140 int count ;
134141
142+ volatile ConsumerPausedEvent event ;
143+
135144 @ KafkaListener (id = "id" , groupId = "grp" ,
136145 topicPartitions = @ org .springframework .kafka .annotation .TopicPartition (topic = "foo" ,
137146 partitions = "#{'0,1,2'.split(',')}" ))
@@ -228,6 +237,12 @@ ConcurrentKafkaListenerContainerFactory kafkaListenerContainerFactory(KafkaListe
228237 return factory ;
229238 }
230239
240+ @ EventListener
241+ public void paused (ConsumerPausedEvent event ) {
242+ this .event = event ;
243+ this .eventLatch .countDown ();
244+ }
245+
231246 }
232247
233248}
0 commit comments