Skip to content

Commit

Permalink
fix : issue with connecting to kafka
Browse files Browse the repository at this point in the history
  • Loading branch information
rajadilipkolli committed Oct 29, 2024
1 parent 4ef30cb commit 005b887
Showing 1 changed file with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import org.springframework.boot.test.context.TestConfiguration;
import org.springframework.boot.testcontainers.service.connection.ServiceConnection;
import org.springframework.context.annotation.Bean;
import org.springframework.test.context.DynamicPropertyRegistrar;
import org.testcontainers.kafka.KafkaContainer;
import org.testcontainers.utility.DockerImageName;

Expand All @@ -15,4 +16,11 @@ public class ContainersConfiguration {
KafkaContainer kafkaContainer() {
return new KafkaContainer(DockerImageName.parse("apache/kafka-native").withTag("3.8.1"));
}

@Bean
DynamicPropertyRegistrar kafkaProperties(KafkaContainer kafkaContainer) {
return (properties) -> {
properties.add("spring.kafka.bootstrapServers", kafkaContainer::getBootstrapServers);
};
}
}

0 comments on commit 005b887

Please sign in to comment.