Skip to content

How to connect kafka in confluent.cloud? #262

Answered by xiaoronglv
xiaoronglv asked this question in Q&A
Discussion options

You must be logged in to vote

After digging into it for 3 hours, I finally figure it out. If you have same question, you can config it in this way.

config = {
  :"bootstrap.servers" => "your-kafka.us-west-2.aws.confluent.cloud:9092",
  :"group.id" => "ruby-test",
  :"security.protocol" => "SASL_SSL",
  :"sasl.mechanism" => "PLAIN",
  :"sasl.username" => 'your username',
  :"sasl.password" => 'your password'

}
consumer = Rdkafka::Config.new(config).consumer
consumer.subscribe("core.onboarding.employees")

consumer.each do |message|
  puts "Message received: #{message}"
end

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by xiaoronglv
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant