Сценарии - Сброс состояния Kafka

Page / - Изменено Alexandr Fokin в 2023/07/15 21:29

Сброс состояния Kafka

Изменено Alexandr Fokin

в 2023/07/15 21:29

Оглавление

public static async Task CleanAsync( KafkaContainer container ) { var connectionString = /* setup connection */; using var client = new AdminClientBuilder( new AdminClientConfig() { BootstrapServers = connectionString } ) .Build(); var metadata = client.GetMetadata(TimeSpan.FromSeconds(5)); var topics = metadata.Topics .Select(e => e.Topic) .Where(e => !e.StartsWith("__")) // Не трогаем системные топики .ToArray(); if (topics.Length != 0) { await client.DeleteTopicsAsync( topics ); } }
Testcontainers, Containers pool
How to get topics list from Kafka using C# https://stackoverflow.com/questions/30819179/how-to-get-topics-list-from-kafka-using-c-sharp Is there a way to purge the topic in Kafka? https://stackoverflow.com/questions/16284399/is-there-a-way-to-purge-the-topic-in-kafka Reset kafka testcontainers without clearing and recreating the testcontainer after every junit test https://stackoverflow.com/questions/72420966/reset-kafka-testcontainers-without-clearing-and-recreating-the-testcontainer-aft/76694930#76694930