Unverified Commit 5032939a authored by Sebastian Schüpbach's avatar Sebastian Schüpbach
Browse files
parent 5dd94ddb
Pipeline #22317 passed with stages
in 5 minutes and 21 seconds
......@@ -19,8 +19,11 @@
package ch.memobase
import ch.memobase.models.{DeleteMessage, ParserIgnore, Report}
import org.apache.kafka.clients.consumer.KafkaConsumer
import org.apache.logging.log4j.scala.Logging
import java.time.Duration
import scala.collection.JavaConverters._
import scala.util.{Failure, Success}
object App
......@@ -32,10 +35,19 @@ object App
with MsgFilter
with Logging {
lazy private val consumer = {
val consumer = new KafkaConsumer[String, String](consumerProps)
logger.debug(s"Subscribing to topic $inputTopic")
consumer.subscribe(List(inputTopic).asJava)
consumer
}
parse(args) match {
case Some((sessionId, filters, dryRun)) =>
try {
for (record <- poll) {
while (true) {
val records = consumer.poll(Duration.ofMillis(pollTimeout)).asScala
for (record <- records) {
Report(record) match {
case Success(rep) =>
if (filters.forall(f => f(rep))) {
......@@ -48,6 +60,7 @@ object App
logger.info(s"${record.value()}")
}
}
}
} catch {
case e: Exception =>
logger.error(e)
......
Markdown is supported
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