lib/rdkafka/consumer.rb
# Subscribe to one or more topics letting Kafka handle partition assignments.
#
# @param topics [Array<String>] One or more topic names
#
# @raise [RdkafkaError] When subscribing fails
#
# @return [nil]
Subscribe to one or more topics letting Kafka handle partition assignments.
Subscribe to one or more topics letting Kafka handle partition assignments .
def subscribe(*topics)
      tpl = TopicPartitionList.new_native_tpl(topics.length)
      topics.each do |topic|
        Rdkafka::Bindings.rd_kafka_topic_partition_list_add(
          tpl,
          topic,
          -1
        )
      end
      response = Rdkafka::Bindings.rd_kafka_subscribe(@native_kafka, tpl)
      if response != 0
        raise Rdkafka::RdkafkaError.new(response, "Error subscribing to '#{topics.join(', ')}'")
      end
    end
def subscribe ( * topics ) tpl = TopicPartitionList . new_native_tpl ( topics . length ) topics . each do | topic | Rdkafka :: Bindings . rd_kafka_topic_partition_list_add ( tpl , topic , - 1 ) end response = Rdkafka :: Bindings . rd_kafka_subscribe ( @native_kafka , tpl ) if response != 0 raise Rdkafka :: RdkafkaError . new ( response , "Error subscribing to '#{topics.join(', ')}'" ) end end
Subscribe to one or more topics letting Kafka handle partition assignments.
Subscribe to one or more topics letting Kafka handle partition assignments .
# Create topic partition list with topics and no partition set # Subscribe to topic partition list and check this was successful
None
nil
[RdkafkaError] When subscribing fails
[ RdkafkaError ] When subscribing fails
topics
One or more topic names
One or more topic names