Created
March 13, 2017 12:47
-
-
Save dselivanov/9604555debe3378256e5bf38253f7f4e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
create_kafka_producer = function(topic, broker_list = "localhost:9092", open = "w") { | |
prodocer_cmd = "kafka-console-producer" | |
# kafka-console-producer --topic test2 --broker-list | |
kafka_pipe = sprintf("%s --topic %s --broker-list %s", prodocer_cmd, topic, broker_list) | |
pipe(kafka_pipe, open = open) | |
} | |
# con = create_kafka_producer("test2", open = "wb") | |
# writeLines("5", con) | |
# flush(con) | |
# close.connection(con) | |
create_kafka_consumer = function(topic, bootstrap_server = "localhost:9092") { | |
consumer_cmd = "kafka-console-consumer" | |
kafka_pipe = sprintf("%s --topic %s --bootstrap-server %s --from-beginning", consumer_cmd, topic, bootstrap_server) | |
pipe(kafka_pipe, open = "r") | |
} | |
# consumer_con = create_kafka_consumer("test2") | |
# messages = readLines(consumer_con) | |
# close.connection(consumer_con) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment