Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 927B2200D50 for ; Mon, 4 Dec 2017 20:59:06 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 910AF160BF9; Mon, 4 Dec 2017 19:59:06 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id D5E9B160BF7 for ; Mon, 4 Dec 2017 20:59:05 +0100 (CET) Received: (qmail 4873 invoked by uid 500); 4 Dec 2017 19:59:05 -0000 Mailing-List: contact jira-help@kafka.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: jira@kafka.apache.org Delivered-To: mailing list jira@kafka.apache.org Received: (qmail 4862 invoked by uid 99); 4 Dec 2017 19:59:05 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd1-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 04 Dec 2017 19:59:05 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd1-us-west.apache.org (ASF Mail Server at spamd1-us-west.apache.org) with ESMTP id 3D181C41FE for ; Mon, 4 Dec 2017 19:59:04 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd1-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -99.211 X-Spam-Level: X-Spam-Status: No, score=-99.211 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, SPF_PASS=-0.001, T_RP_MATCHES_RCVD=-0.01, USER_IN_WHITELIST=-100] autolearn=disabled Received: from mx1-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd1-us-west.apache.org [10.40.0.7]) (amavisd-new, port 10024) with ESMTP id Tbytr2IADdss for ; Mon, 4 Dec 2017 19:59:03 +0000 (UTC) Received: from mailrelay1-us-west.apache.org (mailrelay1-us-west.apache.org [209.188.14.139]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with ESMTP id 84B6D5F3FF for ; Mon, 4 Dec 2017 19:59:01 +0000 (UTC) Received: from jira-lw-us.apache.org (unknown [207.244.88.139]) by mailrelay1-us-west.apache.org (ASF Mail Server at mailrelay1-us-west.apache.org) with ESMTP id B9718E25A0 for ; Mon, 4 Dec 2017 19:59:00 +0000 (UTC) Received: from jira-lw-us.apache.org (localhost [127.0.0.1]) by jira-lw-us.apache.org (ASF Mail Server at jira-lw-us.apache.org) with ESMTP id 2B38F255CA for ; Mon, 4 Dec 2017 19:59:00 +0000 (UTC) Date: Mon, 4 Dec 2017 19:59:00 +0000 (UTC) From: "Matthias J. Sax (JIRA)" To: jira@kafka.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (KAFKA-6302) Topic can not be recreated after it is deleted MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 archived-at: Mon, 04 Dec 2017 19:59:06 -0000 [ https://issues.apache.org/jira/browse/KAFKA-6302?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16277391#comment-16277391 ] Matthias J. Sax commented on KAFKA-6302: ---------------------------------------- Topic deleting is async -- thus, you will need to put a retry logic into place in case the topic did not get deleted yet. > Topic can not be recreated after it is deleted > ---------------------------------------------- > > Key: KAFKA-6302 > URL: https://issues.apache.org/jira/browse/KAFKA-6302 > Project: Kafka > Issue Type: Bug > Components: admin, clients > Affects Versions: 1.0.0 > Reporter: kic > > I use an embedded kafka for unit test. My application relies on the ability to recreate topics programmatically. Currently it is not possible to re-create a topic after it has been deleted. > {code} > // needs compile time depedency 'net.manub:scalatest-embedded-kafka_2.11:1.0.0' and 'org.apache.kafka:kafka-clients:1.0.0' > package kic.kafka.embedded > import java.util.Properties > import org.apache.kafka.clients.admin.{AdminClient, NewTopic} > import org.scalatest._ > import scala.collection.JavaConverters._ > class EmbeddedKafaJavaWrapperTest extends FlatSpec with Matchers { > val props = new Properties() > val testTopic = "test-topic" > "The admin client" should "be able to create, delete and re-create topics" in { > props.setProperty("bootstrap.servers", "localhost:10001") > props.setProperty("delete.enable.topic", "true") > props.setProperty("group.id", "test-client") > props.setProperty("key.deserializer", "org.apache.kafka.common.serialization.LongDeserializer") > props.setProperty("value.deserializer", "org.apache.kafka.common.serialization.StringDeserializer") > props.setProperty("clinet.id", "test-client") > props.setProperty("key.serializer", "org.apache.kafka.common.serialization.LongSerializer") > props.setProperty("value.serializer", "org.apache.kafka.common.serialization.StringSerializer") > EmbeddedKafaJavaWrapper.start(10001, 10002, props) > try { > implicit val admin = AdminClient.create(props) > // create topic and confirm it exists > createTopic(testTopic) > val topics = listTopics() > info(s"topics: $topics") > topics should contain(testTopic) > // now we should be able to send something to this topic > // TODO create producer and send something > // delete topic > deleteTopic(testTopic) > listTopics() shouldNot contain(testTopic) > // recreate topic > createTopic(testTopic) > // listTopics() should contain(testTopic) > // and finally consume from the topic and expect to get 0 entries > // TODO create consumer and poll once > } finally { > EmbeddedKafaJavaWrapper.stop() > } > } > def listTopics()(implicit admin: AdminClient) = > admin.listTopics().names().get() > def createTopic(topic: String)(implicit admin: AdminClient) = > admin.createTopics(Seq(new NewTopic(topic, 1, 1)).asJava) > def deleteTopic(topic: String)(implicit admin: AdminClient) = > admin.deleteTopics(Seq("test-topic").asJava).all().get() > } > {code} > Btw, what happens to connected producers/consumers when I delete a topic? -- This message was sent by Atlassian JIRA (v6.4.14#64029)