# Delete Channel (/sdks/kotlin/how-to/management/delete-channel)



## Overview [#overview]

Deleting a channel is how you decommission a topic, queue, or RPC endpoint you no longer need — tearing down test fixtures between CI runs, retiring a deprecated integration, or cleaning up the throwaway channels a demo or load test created. It's a permanent, immediate operation: the channel's routing entry is removed from the broker and any messages still sitting in it are discarded, so it's not something you want triggered by a typo in a shared environment.

Under the hood, each client exposes typed delete methods that mirror its create methods — `deleteEventsChannel()` on the pub/sub client, `deleteQueuesChannel()` on the queues client, and so on. Because channels are namespaced by type, an events channel and a queues channel can share the same name without colliding, and deleting one never touches the other.

**Gotchas:** attempting to delete a non-existent channel may throw an exception, so idempotent cleanup code should be prepared to catch and ignore that case. There's no "soft delete" or recovery window — once it's gone, any messages still queued are gone with it. And each client only manages its own channel type, so deleting a queues channel requires the queues client, not the pub/sub client, even if you're already connected with the other.

## Prerequisites [#prerequisites]

* KubeMQ server running on `localhost:50000`
* Kotlin SDK installed (`implementation("io.kubemq.sdk:kubemq-sdk-kotlin:1.0.1")`)

## Code [#code]

```kotlin title="DeleteChannelExample.kt"
package io.kubemq.sdk.examples.management

import io.kubemq.sdk.client.KubeMQClient
import kotlinx.coroutines.runBlocking

private const val ADDRESS = "localhost:50000"
private const val CLIENT_ID = "kotlin-management-delete-channel"

fun main() = runBlocking {
    val pubSub = KubeMQClient.pubSub {
        address = ADDRESS
        clientId = CLIENT_ID
    }
    val queues = KubeMQClient.queues {
        address = ADDRESS
        clientId = CLIENT_ID
    }

    pubSub.use { ps ->
        queues.use { q ->
            // Create channels
            ps.createEventsChannel("kotlin-management.delete-events")
            q.createQueuesChannel("kotlin-management.delete-queues")
            println("Created 2 channels.")

            // Delete channels
            ps.deleteEventsChannel("kotlin-management.delete-events")
            println("Deleted events channel: kotlin-management.delete-events")

            q.deleteQueuesChannel("kotlin-management.delete-queues")
            println("Deleted queues channel: kotlin-management.delete-queues")

            println("Done.")
        }
    }
}
```

## How It Works [#how-it-works]

* Each client type has typed `delete*Channel()` methods matching the `create*Channel()` methods.
* Deleting a channel removes it and all associated data from the server.
* Attempting to delete a non-existent channel may throw an exception.

## Related [#related]

* [Create Channel](/sdks/kotlin/how-to/management/create-channel)
* [List Channels](/sdks/kotlin/how-to/management/list-channels)
* [Kotlin SDK Reference](/sdks/kotlin/reference/client)
