remove consumer and update deps
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Torma Kristóf 2021-08-12 12:24:03 +02:00
parent 9793ccc593
commit 3c3beff2e4
Signed by: tormakris
GPG Key ID: DC83C4F2C41B1047
5 changed files with 11 additions and 70 deletions

View File

@ -39,14 +39,12 @@ repositories {
}
dependencies {
compile 'org.postgresql:postgresql:42.2.2'
compile 'org.jetbrains.exposed:exposed-core:0.23.1'
compile 'org.jetbrains.exposed:exposed-dao:0.23.1'
compile 'org.jetbrains.exposed:exposed-jdbc:0.23.1'
compile 'org.jetbrains.exposed:exposed-java-time:0.23.1'
compile 'com.rabbitmq:amqp-client:2.7.1'
compile 'com.zaxxer:HikariCP:2.7.8'
compile 'com.viartemev:the-white-rabbit:0.0.5'
compile 'org.postgresql:postgresql:42.2.23'
compile 'org.jetbrains.exposed:exposed-core:0.33.1'
compile 'org.jetbrains.exposed:exposed-dao:0.33.1'
compile 'org.jetbrains.exposed:exposed-jdbc:0.33.1'
compile 'org.jetbrains.exposed:exposed-java-time:0.33.1'
compile 'com.zaxxer:HikariCP:5.0.0'
implementation "org.koin:koin-ktor:$koin_version"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
implementation "io.ktor:ktor-server-netty:$ktor_version"

View File

@ -1,5 +1,5 @@
ktor_version=1.4.2
ktor_version=1.6.2
kotlin.code.style=official
kotlin_version=1.4.10
logback_version=1.2.1
koin_version=2.2.0
kotlin_version=1.5.21
logback_version=1.2.5
koin_version=2.2.2

View File

@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.2-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.2-all.zip

View File

@ -1,7 +1,6 @@
package com.kmalbz
import com.kmalbz.api.route.OutputServiceRDBServer
import com.kmalbz.consumer.DatabaseConsumer
import io.ktor.application.*
import io.ktor.response.*
import io.ktor.routing.*
@ -12,9 +11,6 @@ import org.apache.http.HttpException
import com.kmalbz.database.DatabaseFactory
import com.kmalbz.database.dao.ResultObjects
import io.ktor.util.KtorExperimentalAPI
import com.rabbitmq.client.*
import com.typesafe.config.ConfigFactory
import io.ktor.config.HoconApplicationConfig
import org.jetbrains.exposed.sql.SchemaUtils
import org.jetbrains.exposed.sql.transactions.transaction
import org.koin.ktor.ext.Koin
@ -39,24 +35,6 @@ fun Application.module() {
SchemaUtils.create(ResultObjects)
}
val appConfig = HoconApplicationConfig(ConfigFactory.load())
val factory = ConnectionFactory()
factory.host = appConfig.property("ktor.mq.host").getString()
factory.username = appConfig.property("ktor.mq.username").getString()
factory.password = appConfig.property("ktor.mq.password").getString()
val connection = factory.newConnection()
val channel = connection.createChannel()
val rabbitExchangeName = appConfig.property("ktor.mq.exchange").getString()
channel.exchangeDeclare(rabbitExchangeName, BuiltinExchangeType.FANOUT)
val queueName = channel.queueDeclare().queue
channel.queueBind(queueName, rabbitExchangeName, "")
channel.basicConsume(queueName, true, DatabaseConsumer())
routing {
install(StatusPages) {
exception<HttpException> {

View File

@ -1,35 +0,0 @@
package com.kmalbz.consumer
import com.google.gson.Gson
import com.kmalbz.api.model.ApiObject
import com.kmalbz.database.service.ResultObjectService
import com.rabbitmq.client.AMQP.BasicProperties
import com.rabbitmq.client.Consumer
import com.rabbitmq.client.Envelope
import com.rabbitmq.client.ShutdownSignalException
class DatabaseConsumer : Consumer {
private val resultObjectService = ResultObjectService()
private val gson = Gson()
override fun handleConsumeOk(consumerTag : String?) {
}
override fun handleCancelOk(p0 : String?) {
throw UnsupportedOperationException()
}
override fun handleRecoverOk(p0 : String?) {
throw UnsupportedOperationException()
}
override fun handleCancel(p0 : String?) {
throw UnsupportedOperationException()
}
override fun handleDelivery(consumerTag : String?, envelope : Envelope?, basicProperties : BasicProperties?, body : ByteArray?) {
val rawJson = body!!.toString(Charsets.UTF_8)
val apiObject = gson.fromJson(rawJson, ApiObject::class.java)
resultObjectService.addOne(apiObject)
}
override fun handleShutdownSignal(p0 : String?, p1 : ShutdownSignalException?) {
println("got shutdown signal")
}
}