remove consumer and update deps
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
9793ccc593
commit
3c3beff2e4
14
build.gradle
14
build.gradle
@ -39,14 +39,12 @@ repositories {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compile 'org.postgresql:postgresql:42.2.2'
|
compile 'org.postgresql:postgresql:42.2.23'
|
||||||
compile 'org.jetbrains.exposed:exposed-core:0.23.1'
|
compile 'org.jetbrains.exposed:exposed-core:0.33.1'
|
||||||
compile 'org.jetbrains.exposed:exposed-dao:0.23.1'
|
compile 'org.jetbrains.exposed:exposed-dao:0.33.1'
|
||||||
compile 'org.jetbrains.exposed:exposed-jdbc:0.23.1'
|
compile 'org.jetbrains.exposed:exposed-jdbc:0.33.1'
|
||||||
compile 'org.jetbrains.exposed:exposed-java-time:0.23.1'
|
compile 'org.jetbrains.exposed:exposed-java-time:0.33.1'
|
||||||
compile 'com.rabbitmq:amqp-client:2.7.1'
|
compile 'com.zaxxer:HikariCP:5.0.0'
|
||||||
compile 'com.zaxxer:HikariCP:2.7.8'
|
|
||||||
compile 'com.viartemev:the-white-rabbit:0.0.5'
|
|
||||||
implementation "org.koin:koin-ktor:$koin_version"
|
implementation "org.koin:koin-ktor:$koin_version"
|
||||||
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
|
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
|
||||||
implementation "io.ktor:ktor-server-netty:$ktor_version"
|
implementation "io.ktor:ktor-server-netty:$ktor_version"
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
ktor_version=1.4.2
|
ktor_version=1.6.2
|
||||||
kotlin.code.style=official
|
kotlin.code.style=official
|
||||||
kotlin_version=1.4.10
|
kotlin_version=1.5.21
|
||||||
logback_version=1.2.1
|
logback_version=1.2.5
|
||||||
koin_version=2.2.0
|
koin_version=2.2.2
|
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
|
|||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
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
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package com.kmalbz
|
package com.kmalbz
|
||||||
|
|
||||||
import com.kmalbz.api.route.OutputServiceRDBServer
|
import com.kmalbz.api.route.OutputServiceRDBServer
|
||||||
import com.kmalbz.consumer.DatabaseConsumer
|
|
||||||
import io.ktor.application.*
|
import io.ktor.application.*
|
||||||
import io.ktor.response.*
|
import io.ktor.response.*
|
||||||
import io.ktor.routing.*
|
import io.ktor.routing.*
|
||||||
@ -12,9 +11,6 @@ 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 io.ktor.util.KtorExperimentalAPI
|
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.SchemaUtils
|
||||||
import org.jetbrains.exposed.sql.transactions.transaction
|
import org.jetbrains.exposed.sql.transactions.transaction
|
||||||
import org.koin.ktor.ext.Koin
|
import org.koin.ktor.ext.Koin
|
||||||
@ -39,24 +35,6 @@ fun Application.module() {
|
|||||||
SchemaUtils.create(ResultObjects)
|
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 {
|
routing {
|
||||||
install(StatusPages) {
|
install(StatusPages) {
|
||||||
exception<HttpException> {
|
exception<HttpException> {
|
||||||
|
@ -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")
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user