class Kafka::Consumer
- Kafka::Consumer
- Reference
- Object
Defined in:
kafka/consumer.crkafka/consumer/rebalance.cr
Constructors
Instance Method Summary
-
#close
Close the consumer and destroy the Kafka handle.
-
#each(timeout = 250, &)
Loops indefinitely calling
#poll
at the given intervaltimeout
. -
#poll(timeout_ms : Int32) : Message | Nil
Poll the consumer for messages or events.
-
#subscribe(*topics)
Subscribe to topics using balanced consumer groups.
Constructor Detail
Instance Method Detail
def close
#
Close the consumer and destroy the Kafka handle.
Calls the rd_kafka_consumer_close
and rd_kafka_destroy
C functions.
def each(timeout = 250, &)
#
Loops indefinitely calling #poll
at the given interval timeout
.
At the beginning of each loop, Fiber.yield
is called allow other Fibers to run.
Poll the consumer for messages or events.
Calls the rd_kafka_consumer_poll
C function.
def subscribe(*topics)
#
Subscribe to topics using balanced consumer groups.
Supports regex - start topic with '^'. For example:
consumer.subcribe("^foo") # will match any topics that starts with foo.
Raises a Kafka::ConsumerException
when the subscribe fails.
Calls the rd_kafka_subscribe
C function.