Skip to content

How to know deterministically know when a consumer is ready? #118

@apeloquin-agilysys

Description

@apeloquin-agilysys

In KafkaJS we make use of the consumer.group_join event for our application to know a consumer is ready to receive messages.

consumer.on(consumer.events.GROUP_JOIN, (event: ConsumerGroupJoinEvent) => {
  // inform app this consumer is ready
});

Per #38, the on methods don't appear to be on the immediate road map.

About the on methods, we don't plan to implement them yet.

I'm wondering if you have an alternative approach we can use to ascertain consumer readiness?

Originally we were using this:

consumer.assignment().length > 0

Unfortunately, it turns out that when you have a topic with more consumers than partitions, the consumers that don't get a partition also never satisfy this condition.

I see we get log entries:

{
  "message": "Consumer connected",
  "extra": {
    "fac": "BINDING",
    "name": "undefined#consumer-1"
  }
}

...but even if we were to hijack these events with our own Logger, I see no way to tie the name back to the consumers created (in our case we may have dozens).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions