Sha256: 59238a3ceede2bcca673bd64eda6200aa3783785a8ec219f43cf3746e5301317

Contents?: true

Size: 462 Bytes

Versions: 38

Compression:

Stored size: 462 Bytes

Contents

# 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

Version data entries

38 entries across 38 versions & 1 rubygems

Version Path
ruby-kafka-0.5.2 ci/producer.rb
ruby-kafka-0.5.2.beta3 ci/producer.rb
ruby-kafka-0.5.2.beta2 ci/producer.rb
ruby-kafka-0.5.2.beta1 ci/producer.rb
ruby-kafka-0.5.1 ci/producer.rb
ruby-kafka-0.5.1.beta2 ci/producer.rb
ruby-kafka-0.5.1.beta1 ci/producer.rb
ruby-kafka-0.4.4 ci/producer.rb
ruby-kafka-0.5.0 ci/producer.rb
ruby-kafka-0.5.0.beta6 ci/producer.rb
ruby-kafka-0.5.0.beta5 ci/producer.rb
ruby-kafka-0.5.0.beta4 ci/producer.rb
ruby-kafka-0.5.0.beta3 ci/producer.rb
ruby-kafka-0.5.0.beta2 ci/producer.rb
ruby-kafka-0.4.3 ci/producer.rb
ruby-kafka-0.4.2 ci/producer.rb
ruby-kafka-0.4.1 ci/producer.rb
ruby-kafka-0.4.0 ci/producer.rb
ruby-kafka-0.4.0.beta1 ci/producer.rb
ruby-kafka-0.3.18.beta2 ci/producer.rb