From 3c3beff2e4ed5378d5db6c50960dbe844cb84587 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torma=20Krist=C3=B3f?= Date: Thu, 12 Aug 2021 12:24:03 +0200 Subject: [PATCH] remove consumer and update deps --- build.gradle | 14 ++++------ gradle.properties | 8 +++--- gradle/wrapper/gradle-wrapper.properties | 2 +- src/Application.kt | 22 --------------- src/consumer/DatabaseConsumer.kt | 35 ------------------------ 5 files changed, 11 insertions(+), 70 deletions(-) delete mode 100644 src/consumer/DatabaseConsumer.kt diff --git a/build.gradle b/build.gradle index 08304b9..42e4e93 100644 --- a/build.gradle +++ b/build.gradle @@ -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" diff --git a/gradle.properties b/gradle.properties index a1c1bc9..2b0b6f4 100644 --- a/gradle.properties +++ b/gradle.properties @@ -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 \ No newline at end of file +kotlin_version=1.5.21 +logback_version=1.2.5 +koin_version=2.2.2 \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 6b47e69..29d63b8 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -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 diff --git a/src/Application.kt b/src/Application.kt index 2a87878..d2e55dc 100644 --- a/src/Application.kt +++ b/src/Application.kt @@ -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 { diff --git a/src/consumer/DatabaseConsumer.kt b/src/consumer/DatabaseConsumer.kt deleted file mode 100644 index ea5b670..0000000 --- a/src/consumer/DatabaseConsumer.kt +++ /dev/null @@ -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") - } -} \ No newline at end of file