Skip to content

[Bug]: Finalizing JUnit 5 test case with Kafka Streams and Spring Boot takes several minutes #8948

Discussion options

You must be logged in to vote

I was digging a little bit more on this and I ended up doing this

  1. Create an AfterAllCallback implementation
static class KafkaStreamsCallback implements AfterAllCallback {

        @Override
        public void afterAll(ExtensionContext extensionContext) throws Exception {
            ApplicationContext applicationContext = SpringExtension.getApplicationContext(extensionContext);
            KafkaStreams kafkaStreams = applicationContext.getBean(KafkaStreams.class);
            kafkaStreams.close();
        }
    }
  1. Register KafkaStreamsCallback at test class level @ExtendWith(DemoLongKafkaStreamsTeardownApplicationTests.KafkaStreamsCallback.class)

Replies: 8 comments 4 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

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

@MarvinVaillant
Comment options

@eddumelendez
Comment options

Answer selected by MarvinVaillant
@MarvinVaillant
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
2 participants
Converted from issue

This discussion was converted from issue #8867 on July 15, 2024 21:47.