THIS PROJECT IS STILL ALPHA CURRENTLY -- Check back often!!
fRanz is an open source R kafka client that allows users to read and write messages from kafka. It leverages the stability and performance of librdkafka and implements ididiomatic R workflows ontop of it.
library(fRanz)
BROKER_HOST<-'localhost'BROKER_PORT<-9092TOPIC_NAME<-'myTestTopic'# KafkaBrokerbroker<-KafkaBroker$new(host=BROKER_HOST, port=BROKER_PORT)
# KafkaProducerproducer<-KafkaProducer$new(brokers=list(broker))
producer$produce(topic=TOPIC_NAME,
key="myKey",
value="My First Message")
# Number of messages successfuly sent is returned# [1] 1 # KafkaConsumerconsumer<-KafkaConsumer$new(brokers=list(broker), groupId="test", extraOptions=list(`auto.offset.reset`="earliest"))
consumer$subscribe(topics= c(TOPIC_NAME))
result<-consumer$consume(topic=TOPIC_NAME)
result# Consumed messages are returned in a list(list(key,val)) format# [[1]]# [[1]]$key# [1] "myKey"## [[1]]$payload# [1] "My First Message" 