How can I declare diff topics in supervisor using kafka_ex? I already follow this instruction: https://hexdocs.pm/kafka_ex/KafkaEx.ConsumerGroup.html
My code:
children = [
supervisor(
KafkaEx.ConsumerGroup,
[
MyConsumer1,
"consumer_group_name",
"my-topic1",
@opts
]
),
supervisor(
KafkaEx.ConsumerGroup,
[
MyConsumer2,
"consumer_group_name",
"my-topic2",
@opts
]
)
]
It returns
children = [
Supervisor.child_spec({MyWorker, arg}, id: :my_worker_1),
Supervisor.child_spec({MyWorker, arg}, id: :my_worker_2)
]
** (Mix) Could not start application myapp: MyApp.Application.start(:normal, []) returned an error: bad child specification, more than one child specification has the id: KafkaEx.ConsumerGroup.
If using maps as child specifications, make sure the :id keys are unique.
If using a module or {module, arg} as child, use Supervisor.child_spec/2 to change the :id, for example:
children = [
Supervisor.child_spec({MyWorker, arg}, id: :my_worker_1),
Supervisor.child_spec({MyWorker, arg}, id: :my_worker_2)
]
It suggests that I have to make a different KafkaEx.ConsumerGroup
for the id but there’s only one in kafka_ex. Please help. Can’t find any solution. What’s the syntax for that?