最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Can a Kafka topic be deleted and then recreated in the same order? - Stack Overflow

programmeradmin3浏览0评论

We have a bunch of topics, which were created with 4 partitions, whereas they should each have one.

Because the partitions-count cannot be lowered, I'm trying to delete each such topic, and then recreate it anew. The body of the loop iterating over the list of topics is:

        orderid=$(post $ORDERS -d '{}')
        post --data-binary @- $ORDERS/$orderid/items <<- EOJ
        {
            "productType": "KafkaTopic",
            "actionType": "delete",
            "parameters": {
                "name": "$topic",
                "clusterId": "$cluster",
                "ownerDeployment": "$owner"
            }
        }
        EOJ
        post --data-binary @- $ORDERS/$orderid/items <<- EOJ
        {
            "productType": "KafkaTopic",
            "actionType": "create",
            "parameters": {
                "name": "$topic",
                "clusterId": "$cluster",
                "ownerDeployment": "$owner",
                "numPartitions": 1
            }
        }
        EOJ
        post $ORDERS/$orderid/submit | python3.11 -m json.tool

However, the order-submissions all fail with "A topic named 'thetopic' already exists on cluster thecluster."

Must I separate the deletion and the (re)creation into separate orders? Would rather not...

Is there some other trick to it?

发布评论

评论列表(0)

  1. 暂无评论