confluentinc / confluentinc/confluent-kafka-javascript

### Feature Request: Add Support for `stop` Method in Kafka Consumer

Open
#302 1 comment 0 reactions 0 assignees View on GitHub
status:waiting-for-interest
Dominant language
TypeScript
Stars
304
Forks
45
Avg merge
11h 47m
Merged PRs (30d)
5

Description

### Feature Request: Add Support for `stop` Method in Kafka Consumer

#### Description
The `stop` method is currently not supported in the Confluent Kafka JavaScript client, as noted in the [migration guide](https://docs.confluent.io/kafka-clients/javascript/current/migration.html). The recommended workaround is to disconnect the consumer, but this approach has limitations in scenarios where pausing and resuming consumption is required without fully disconnecting.

#### Use Case
In our test suite, we need to:
1. Consume all existing messages from a topic.
2. Pause the consumer to produce new test messages.
3. Resume the consumer to consume only the newly produced messages.

Using `disconnect` as a workaround requires reinitializing the consumer and handling group rebalancing, which is both error-prone and inefficient. Similarly, `pause` and `resume` do not allow us to reconfigure the callback logic dynamically, as the `run` method cannot be called again after the consumer is already running.

#### Proposed Solution
- Allows pausing message consumption without fully disconnecting the consumer.
- Supports re-executing the run method to dynamically adjust the callback logic or reset the consumer's state.

#### Additional Context
- [Migration Guide](https://docs.confluent.io/kafka-clients/javascript/current/migration.html)
- Current workaround: Disconnecting and reconnecting the consumer.
- Using `pause` and `resume`, which does not allow re-executing the `run` method to adjust callback logic dynamically.

Thank you for considering this feature request!

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.