Verified Commit 8963b2c3 authored by Sebastian Schüpbach's avatar Sebastian Schüpbach
Browse files

add basic Kafka message handling

parent 4c2a48a7
......@@ -28,6 +28,7 @@ lazy val root = (project in file("."))
mariadbJdbcDriver,
memobaseServiceUtils,
scalatic,
sprayJson,
scalaTest % Test)
)
......@@ -32,4 +32,5 @@ object Dependencies {
lazy val memobaseServiceUtils = "org.memobase" % "memobase-service-utilities" % "1.2.1"
lazy val scalatic = "org.scalactic" %% "scalactic" % scalatestV
lazy val scalaTest = "org.scalatest" %% "scalatest" % scalatestV
lazy val sprayJson = "io.spray" %% "spray-json" % "1.3.5"
}
{
"timestamp": "20200602T083300+02:00",
"object_id": 3242123,
"event": "update"
}
\ No newline at end of file
/*
* Extracts media files from Fedora repository
* Copyright (C) 2020 Memoriav
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package org.memobase.models
import spray.json._
case class KafkaMessage(id: String,
event: String,
timestamp: String)
//noinspection TypeAnnotation
object KafkaMessageProtocol extends DefaultJsonProtocol {
implicit val kafkaMessageFormat = jsonFormat3(KafkaMessage)
}
object KafkaMessageLoader {
import KafkaMessageProtocol._
def load(msg: String): KafkaMessage = {
msg.parseJson.convertTo[KafkaMessage]
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment