Pulsar.ConsumerGroup (Pulsar v2.8.13)

Copy Markdown View Source

A supervisor that manages a group of consumer processes for a single topic.

This module provides a reusable abstraction for creating and managing consumer groups, whether for regular topics or individual partitions within a partitioned topic.

Each consumer group manages multiple consumer processes (configurable via consumer_count) that all subscribe to the same topic with the same subscription configuration.

Summary

Functions

Returns a specification to start this module under a supervisor.

Gets all consumer process PIDs managed by this consumer group.

Stops a consumer group supervisor and all its child consumer processes.

Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

get_consumers(supervisor_pid)

Gets all consumer process PIDs managed by this consumer group.

Returns a list of consumer PIDs.

start_link(name, topic, subscription_name, subscription_type, callback_module, opts \\ [])

Starts a consumer group supervisor.

Parameters

  • name - Unique name for this consumer group
  • topic - The topic to subscribe to
  • subscription_name - Name of the subscription
  • subscription_type - Type of subscription (e.g., :Exclusive, :Shared, :Key_Shared)
  • callback_module - Module that implements Pulsar.Consumer.Callback behaviour
  • opts - Additional options:
    • :consumer_count - Number of consumer processes in this group (default: 1)
    • Other options passed to individual consumer processes

Returns

{:ok, pid} - The consumer group supervisor PID {:error, reason} - Error if the supervisor failed to start

stop(supervisor_pid, reason \\ :normal, timeout \\ :infinity)

Stops a consumer group supervisor and all its child consumer processes.