Skip to content

Commit

Permalink
KafkaDevServicesDevModeTestCase instability fix : delete topic at app…
Browse files Browse the repository at this point in the history
… startup

to avoid receiving records from previous execution
  • Loading branch information
ozangunalp committed Feb 15, 2024
1 parent 754f4e4 commit dd53706
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public class KafkaDevServicesDevModeTestCase {
@Override
public JavaArchive get() {
return ShrinkWrap.create(JavaArchive.class)
.addClasses(PriceConverter.class, PriceResource.class, PriceGenerator.class)
.addClasses(PriceConverter.class, PriceResource.class, PriceGenerator.class, TopicCleaner.class)
.addAsResource(new StringAsset(FINAL_APP_PROPERTIES),
"application.properties");
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package io.quarkus.smallrye.reactivemessaging.kafka.deployment.dev;

import jakarta.enterprise.context.ApplicationScoped;
import jakarta.enterprise.event.Observes;
import jakarta.inject.Inject;

import io.quarkus.kafka.client.runtime.KafkaAdminClient;
import io.quarkus.runtime.StartupEvent;

@ApplicationScoped
public class TopicCleaner {

@Inject
KafkaAdminClient adminClient;

void startup(@Observes StartupEvent event) {
adminClient.deleteTopic("prices");
}
}

0 comments on commit dd53706

Please sign in to comment.