KafkaMessageBus v0.2.0 KafkaMessageBus.Consumer View Source

Link to this section Summary

Functions

Invoked for each message set consumed from a Kafka topic partition

Invoked when the server is started. start_link/5 will block until it returns

Link to this section Functions

Link to this function handle_call(call, from, consumer_state) View Source

Invoked by KafkaEx.GenConsumer.call/3.

Note the default implementation will cause a MatchError. If you want to interact with your consumer, you must implement a handle_call function.

Callback implementation for KafkaEx.GenConsumer.handle_call/3.

Link to this function handle_message_set(message_set, state) View Source

Invoked for each message set consumed from a Kafka topic partition.

message_set is a message set fetched from a Kafka broker and state is the current state of the KafkaEx.GenConsumer.

Returning {:async_commit, new_state} acknowledges message and continues to consume from the Kafka queue with new state new_state. Acknowledged messages will be auto-committed (possibly at a later time) based on the :commit_interval and :commit_threshold options.

Returning {:sync_commit, new_state} commits message synchronously before continuing to consume from the Kafka queue with new state new_state. Committing a message synchronously means that no more messages will be consumed until the message’s offset is committed. :sync_commit should be used sparingly, since committing every message synchronously would impact a consumer’s performance and could result in excessive network traffic.

Callback implementation for KafkaEx.GenConsumer.handle_message_set/2.

Invoked when the server is started. start_link/5 will block until it returns.

topic and partition are the arguments passed to start_link/5. They identify the Kafka partition that the KafkaEx.GenConsumer will consume from.

Returning {:ok, state} will cause start_link/5 to return {:ok, pid} and the process to start consuming from its assigned partition. state becomes the consumer’s state.

Any other return value will cause the start_link/5 to return {:error, error} and the process to exit.

Callback implementation for KafkaEx.GenConsumer.init/2.