diff --git a/resources/application.conf b/resources/application.conf index 6f4b7c9..3b2b44c 100644 --- a/resources/application.conf +++ b/resources/application.conf @@ -15,5 +15,7 @@ ktor { host = ${MQ_HOST} username = ${MQ_USERNAME} password = ${MQ_PASSWORD} + exchange = "output" + exchange = ${?MQ_EXCHANGE} } } \ No newline at end of file diff --git a/src/Application.kt b/src/Application.kt index 575a372..7c05bee 100644 --- a/src/Application.kt +++ b/src/Application.kt @@ -16,7 +16,6 @@ import org.apache.http.HttpException import com.kmalbz.database.DatabaseFactory import com.kmalbz.database.dao.ResultObjects import com.kmalbz.database.service.ResultObjectService -import com.kmalbz.mq.RecieveOutput import io.ktor.util.KtorExperimentalAPI import com.rabbitmq.client.* import com.typesafe.config.ConfigFactory @@ -60,9 +59,11 @@ fun Application.module(testing: Boolean = false) { val connection = factory.newConnection() val channel = connection.createChannel() - channel.exchangeDeclare(RecieveOutput.EXCHANGE_NAME, BuiltinExchangeType.FANOUT) + val rabbitExchangeName = appConfig.property("ktor.mq.exchange").getString() + + channel.exchangeDeclare(rabbitExchangeName, BuiltinExchangeType.FANOUT) val queueName = channel.queueDeclare().queue - channel.queueBind(queueName, RecieveOutput.EXCHANGE_NAME, "") + channel.queueBind(queueName, rabbitExchangeName, "") GlobalScope.launch(Dispatchers.Default) { connection.channel { @@ -80,14 +81,6 @@ fun Application.module(testing: Boolean = false) { } routing { - get("/") { - call.respondText("HELLO WORLD!", contentType = ContentType.Text.Plain) - } - - get("/json/gson") { - call.respond(mapOf("hello" to "world")) - } - install(StatusPages) { exception { _ -> call.respond(HttpStatusCode.Unauthorized) diff --git a/src/mq/RecieveOutput.kt b/src/mq/RecieveOutput.kt deleted file mode 100644 index 7face87..0000000 --- a/src/mq/RecieveOutput.kt +++ /dev/null @@ -1,7 +0,0 @@ -package com.kmalbz.mq - -class RecieveOutput { - companion object { - const val EXCHANGE_NAME = "output" - } -} \ No newline at end of file