Skip to content

Latest commit

 

History

History
21 lines (14 loc) · 769 Bytes

README.md

File metadata and controls

21 lines (14 loc) · 769 Bytes

Ruby example for CloudKarafka

Simple example on how to use ruby and rdkafka-ruby to produce and consume messages on a CloudKarafka Instance

Setup and run

First, install rdkafka gem gem install rdkafka

To configure the consumer and producer to use your credentials this example uses environment variables. An easy way to handle these is using dotenv and store all variables in a .env file like so:

CLOUDKARAFKA_HOSTNAME=rocket.srvs.cloudkafka.com
CLOUDKARAFKA_USERNAME=username
CLOUDKARAFKA_PASSWORD=password

and then you run the scripts like this:

dotenv ruby producer.rb or dotenv ruby consumer.rb

dotenv will read the .env file and set these as environment variables for the ruby process