Skip to content

How to fail SpringBootApplication fail on unknown Kafka topicname, group-id and such? #3002

Answered by JooHyukKim
JooHyukKim asked this question in Q&A
Discussion options

You must be logged in to vote

Found workaround.

  • Made my @Compontent with @KafkaListener annotoation to implement ApplicationRunner.
  • in run command, validates existent of needed topic by the compontent itself.
  • WARNING : quite verbose, but trying to not let the sever run unintneded.
/**
     * At the start of the Application, this method verifies the connection to Kafka and the existence of a specific topic.
     */
    @Throws(Exception::class)
    override fun run(args: ApplicationArguments) {
        // Creating an Admin Client
        val config = Properties()
        // Setting the address of the Kafka broker
        config[AdminClientConfig.BOOTSTRAP_SERVERS_CONFIG] = bootstrapServers
        // Establishing a c…

Replies: 1 comment 4 replies

Comment options

You must be logged in to vote
4 replies
@artembilan
Comment options

@Casper-dss
Comment options

@Casper-dss
Comment options

@JooHyukKim
Comment options

Answer selected by JooHyukKim
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants