All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.lemfi.kest.rabbitmq.executor.RabbitMQQueueDeletionExecution.kt Maven / Gradle / Ivy

There is a newer version: 0.8.1
Show newest version
package com.github.lemfi.kest.rabbitmq.executor

import com.github.lemfi.kest.core.logger.LoggerFactory
import com.github.lemfi.kest.core.model.Execution
import com.rabbitmq.client.ConnectionFactory
import java.net.URLEncoder

internal class RabbitMQQueueDeletionExecution(
    private val queue: String,
    private val connection: String,
    private val vhost: String,
) : Execution() {

    private val encodedVhost: String = URLEncoder.encode(vhost, Charsets.UTF_8)

    override fun execute() {

        LoggerFactory.getLogger("RABBITMQ-Kest")
            .info(
                """
                |Queue deletion:
                |
                |vhost: $vhost
                |name: $queue
                """.trimMargin()
            )

        ConnectionFactory().also {
            it.setUri("$connection/$encodedVhost")
        }
            .newConnection("kest connection")
            .createChannel()
            .apply {
                queueDelete(queue)
            }
            .connection.close()
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy