Class: Kafka::KafkaProducer
- Inherits:
-
Object
- Object
- Kafka::KafkaProducer
- Defined in:
- lib/jruby-kafka/kafka-producer.rb
Overview
noinspection JRubyStringImportInspection
Defined Under Namespace
Classes: RubyCallback
Instance Attribute Summary collapse
-
#properties ⇒ Object
readonly
Returns the value of attribute properties.
Instance Method Summary collapse
-
#initialize(opts = {}) ⇒ KafkaProducer
constructor
Create a Kafka producer.
-
#send_msg(topic, partition, key, value, timestamp = nil, &block) ⇒ Object
Send a message to the cluster.
Constructor Details
#initialize(opts = {}) ⇒ KafkaProducer
Create a Kafka producer.
For other configuration properties and their default values see kafka.apache.org/documentation.html#producerconfigs and kafka.apache.org/0100/javadoc/index.html?org/apache/kafka/clients/consumer/KafkaConsumer.html.
35 36 37 38 |
# File 'lib/jruby-kafka/kafka-producer.rb', line 35 def initialize(opts = {}) @properties = opts.clone super Kafka::Utility.java_properties @properties end |
Instance Attribute Details
#properties ⇒ Object (readonly)
Returns the value of attribute properties.
21 22 23 |
# File 'lib/jruby-kafka/kafka-producer.rb', line 21 def properties @properties end |
Instance Method Details
#send_msg(topic, partition, key, value, timestamp = nil, &block) ⇒ Object
Send a message to the cluster.
54 55 56 57 58 59 60 61 62 |
# File 'lib/jruby-kafka/kafka-producer.rb', line 54 def send_msg(topic, partition, key, value, =nil, &block) record = ProducerRecord.new(topic, partition, , key, value) if block send_cb_method record, RubyCallback.new(block) else send_method record end end |