D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
opt
/
td-agent
/
embedded
/
lib
/
ruby
/
gems
/
2.1.0
/
gems
/
ruby-kafka-0.4.2
/
ci
/
Filename :
producer.rb
back
Copy
# Continuously produces messages to a Kafka topic. require_relative "init" producer = $kafka.async_producer( delivery_interval: 1, max_queue_size: 5_000, max_buffer_size: 10_000, ) num_messages = 0 shutdown = false trap("TERM") { shutdown = true } until shutdown begin producer.produce("hello", key: "world", topic: "greetings") rescue Kafka::BufferOverflow puts "Buffer overflow, backing off..." sleep 10 end end producer.shutdown