@@ -105,10 +105,10 @@ public static String bootstrapServers() {
105
105
List <ConsumerFactory <String , Object >> avroJacksonConsumerFactories = new ArrayList <>();
106
106
107
107
@ Autowired (required = false )
108
- ConsumerFactory <String , GenericRecord > avroConsumerFactory ;
108
+ List < ConsumerFactory <String , GenericRecord >> avroConsumerFactories = new ArrayList <>() ;
109
109
110
110
@ Autowired (required = false )
111
- ConsumerFactory <String , String > jsonConsumerFactory ;
111
+ List < ConsumerFactory <String , String >> jsonConsumerFactories = new ArrayList <>() ;
112
112
113
113
@ Autowired (required = false )
114
114
private KafkaListenerEndpointRegistry registry ;
@@ -189,7 +189,7 @@ public void a_message_is_consumed_from_a_topic(Guard guard, String name, boolean
189
189
guard .in (objects , () -> {
190
190
KafkaInterceptor .awaitForSuccessfullOnly = successfully ;
191
191
if (!checkedTopics .contains (topic )) {
192
- try (Admin admin = Admin .create (avroConsumerFactory .getConfigurationProperties ())) {
192
+ try (Admin admin = Admin .create (avroConsumerFactories . get ( 0 ) .getConfigurationProperties ())) {
193
193
awaitUntil (() -> {
194
194
List <String > groupIds = admin .listConsumerGroups ().all ().get ().stream ().map (ConsumerGroupListing ::groupId ).toList ();
195
195
Map <String , KafkaFuture <ConsumerGroupDescription >> groupDescriptions = admin .describeConsumerGroups (groupIds ).describedGroups ();
@@ -223,7 +223,7 @@ public void a_message_is_consumed_from_a_topic(Guard guard, String name, boolean
223
223
@ When (THAT + GUARD + "the " + VARIABLE + " group id has fully consumed the " + VARIABLE + " topic$" )
224
224
public void topic_has_been_consumed_on_every_partition (Guard guard , String groupId , String topic ) {
225
225
guard .in (objects , () -> awaitUntilAsserted (() -> getAllConsumers (topic ).forEach (consumer -> unchecked (() -> {
226
- try (Admin admin = Admin .create (avroConsumerFactory .getConfigurationProperties ())) {
226
+ try (Admin admin = Admin .create (avroConsumerFactories . get ( 0 ) .getConfigurationProperties ())) {
227
227
Map <TopicPartition , OffsetAndMetadata > topicPartitionOffsetAndMetadataMap = admin
228
228
.listConsumerGroupOffsets (groupId )
229
229
.partitionsToOffsetAndMetadata ().get ();
@@ -241,7 +241,7 @@ public void topic_has_been_consumed_on_every_partition(Guard guard, String group
241
241
242
242
@ Given (THAT + "the current offset of " + VARIABLE + " on the topic " + VARIABLE + " is (\\ d+)$" )
243
243
public void that_the_current_offset_the_groupid_on_topic_is (String groupId , String topic , long offset ) throws ExecutionException , InterruptedException {
244
- try (Admin admin = Admin .create (avroConsumerFactory .getConfigurationProperties ())) {
244
+ try (Admin admin = Admin .create (avroConsumerFactories . get ( 0 ) .getConfigurationProperties ())) {
245
245
admin .listConsumerGroupOffsets (groupId ).partitionsToOffsetAndMetadata ().get ();
246
246
TopicPartition topicPartition = new TopicPartition (topic , 0 );
247
247
Collection <MemberDescription > members = admin .describeConsumerGroups (List .of (groupId )).describedGroups ().get (groupId ).get ().members ();
@@ -432,17 +432,17 @@ public List<Consumer<String, Object>> getAvroJacksonConsumers(String topic) {
432
432
}
433
433
434
434
public Consumer <String , GenericRecord > getAvroConsumer (String topic ) {
435
- if (avroConsumerFactory == null ) {
435
+ if (avroConsumerFactories . isEmpty () ) {
436
436
return null ;
437
437
}
438
- return avroConsumers .computeIfAbsent (topic , t -> avroConsumerFactory .createConsumer (UUID .randomUUID () + "_avro_" + t , "" ));
438
+ return avroConsumers .computeIfAbsent (topic , t -> avroConsumerFactories . get ( 0 ) .createConsumer (UUID .randomUUID () + "_avro_" + t , "" ));
439
439
}
440
440
441
441
public Consumer <String , String > getJsonConsumer (String topic ) {
442
- if (jsonConsumerFactory == null ) {
442
+ if (jsonConsumerFactories . isEmpty () ) {
443
443
return null ;
444
444
}
445
- return jsonConsumers .computeIfAbsent (topic , t -> this .jsonConsumerFactory .createConsumer (UUID .randomUUID () + "_json_" + t , "" ));
445
+ return jsonConsumers .computeIfAbsent (topic , t -> this .jsonConsumerFactories . get ( 0 ) .createConsumer (UUID .randomUUID () + "_json_" + t , "" ));
446
446
}
447
447
448
448
@ NotNull
0 commit comments