Compare commits
No commits in common. "cb3f9874a8e613bebb3cf144b1e0704c52f47718" and "647242ff372ea48aeed4baa306da916b3b3ee7c6" have entirely different histories.
cb3f9874a8
...
647242ff37
@ -15,7 +15,5 @@ ktor {
|
|||||||
host = ${MQ_HOST}
|
host = ${MQ_HOST}
|
||||||
username = ${MQ_USERNAME}
|
username = ${MQ_USERNAME}
|
||||||
password = ${MQ_PASSWORD}
|
password = ${MQ_PASSWORD}
|
||||||
exchange = "output"
|
|
||||||
exchange = ${?MQ_EXCHANGE}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -16,6 +16,7 @@ import org.apache.http.HttpException
|
|||||||
import com.kmalbz.database.DatabaseFactory
|
import com.kmalbz.database.DatabaseFactory
|
||||||
import com.kmalbz.database.dao.ResultObjects
|
import com.kmalbz.database.dao.ResultObjects
|
||||||
import com.kmalbz.database.service.ResultObjectService
|
import com.kmalbz.database.service.ResultObjectService
|
||||||
|
import com.kmalbz.mq.RecieveOutput
|
||||||
import io.ktor.util.KtorExperimentalAPI
|
import io.ktor.util.KtorExperimentalAPI
|
||||||
import com.rabbitmq.client.*
|
import com.rabbitmq.client.*
|
||||||
import com.typesafe.config.ConfigFactory
|
import com.typesafe.config.ConfigFactory
|
||||||
@ -59,11 +60,9 @@ fun Application.module(testing: Boolean = false) {
|
|||||||
val connection = factory.newConnection()
|
val connection = factory.newConnection()
|
||||||
val channel = connection.createChannel()
|
val channel = connection.createChannel()
|
||||||
|
|
||||||
val rabbitExchangeName = appConfig.property("ktor.mq.exchange").getString()
|
channel.exchangeDeclare(RecieveOutput.EXCHANGE_NAME, BuiltinExchangeType.FANOUT)
|
||||||
|
|
||||||
channel.exchangeDeclare(rabbitExchangeName, BuiltinExchangeType.FANOUT)
|
|
||||||
val queueName = channel.queueDeclare().queue
|
val queueName = channel.queueDeclare().queue
|
||||||
channel.queueBind(queueName, rabbitExchangeName, "")
|
channel.queueBind(queueName, RecieveOutput.EXCHANGE_NAME, "")
|
||||||
|
|
||||||
GlobalScope.launch(Dispatchers.Default) {
|
GlobalScope.launch(Dispatchers.Default) {
|
||||||
connection.channel {
|
connection.channel {
|
||||||
@ -81,6 +80,14 @@ fun Application.module(testing: Boolean = false) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
routing {
|
routing {
|
||||||
|
get("/") {
|
||||||
|
call.respondText("HELLO WORLD!", contentType = ContentType.Text.Plain)
|
||||||
|
}
|
||||||
|
|
||||||
|
get("/json/gson") {
|
||||||
|
call.respond(mapOf("hello" to "world"))
|
||||||
|
}
|
||||||
|
|
||||||
install(StatusPages) {
|
install(StatusPages) {
|
||||||
exception<AuthenticationException> { _ ->
|
exception<AuthenticationException> { _ ->
|
||||||
call.respond(HttpStatusCode.Unauthorized)
|
call.respond(HttpStatusCode.Unauthorized)
|
||||||
|
7
src/mq/RecieveOutput.kt
Normal file
7
src/mq/RecieveOutput.kt
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
package com.kmalbz.mq
|
||||||
|
|
||||||
|
class RecieveOutput {
|
||||||
|
companion object {
|
||||||
|
const val EXCHANGE_NAME = "output"
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user