Commit 16c6fddf authored by Thomas Bernhart's avatar Thomas Bernhart
Browse files

Add logging to Consumer

parent b964e3ee
Pipeline #22040 passed with stages
in 4 minutes and 22 seconds
...@@ -22,15 +22,19 @@ import java.time.Duration ...@@ -22,15 +22,19 @@ import java.time.Duration
import java.util.Properties import java.util.Properties
import org.apache.kafka.clients.consumer.ConsumerRecords import org.apache.kafka.clients.consumer.ConsumerRecords
import org.apache.kafka.clients.consumer.KafkaConsumer import org.apache.kafka.clients.consumer.KafkaConsumer
import org.apache.logging.log4j.LogManager
import org.apache.logging.log4j.Logger
class Consumer(props: Properties, topic: String) : Closeable { class Consumer(props: Properties, topic: String) : Closeable {
private val instance = KafkaConsumer<String, String>(props) private val instance = KafkaConsumer<String, String>(props)
private val log: Logger = LogManager.getLogger("FedoraIngestConsumer")
init { init {
instance.subscribe(listOf(topic)) instance.subscribe(listOf(topic))
} }
fun fetchRecords(): ConsumerRecords<String, String> { fun fetchRecords(): ConsumerRecords<String, String> {
log.info("Polling for new records.")
return instance.poll(Duration.ofMillis(1000)) return instance.poll(Duration.ofMillis(1000))
} }
......
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