Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for commitOffsets functions from kafkajs in class ClientKafka #9258

Closed
1 task done
davidschuette opened this issue Feb 24, 2022 · 4 comments
Closed
1 task done
Labels
needs triage This issue has not been looked into type: enhancement 🐺

Comments

@davidschuette
Copy link
Contributor

Is there an existing issue that is already proposing this?

  • I have searched the existing issues

Is your feature request related to a problem? Please describe it

There is no option to manually commit offsets when comsuming kafka events.

Describe the solution you'd like

Provide commitOffsets function from native kafkajs via ClientKafka implementation.

constructor(@Inject('KAFKA') private readonly client: ClientKafka) {}
...
@EventPattern('pattern')
consumeEvent(@Payload() data: any, @Ctx() context: KafkaContext) {
  this.client.commitOffsets(...)
}

If this idea gets approval I will start working on a PR and I am happy to update the docs as well.

Teachability, documentation, adoption, migration strategy

Developers will be able to manually commit offsets instead of auto commit. In production this is essential when using kafka.

What is the motivation / use case for changing the behavior?

Need to manually commit offsets when working with kafka in production.

@davidschuette davidschuette added needs triage This issue has not been looked into type: enhancement 🐺 labels Feb 24, 2022
@kamilmysliwiec
Copy link
Member

Contributions are more than welcome!

@davidschuette
Copy link
Contributor Author

These are all the changes I am planing to make to ClientKafka.

public commitOffsets(
  topicPartitions: TopicPartitionOffsetAndMetadata[],
): Promise<void> {
  return this.consumer.commitOffsets(topicPartitions);
}

Does such a simple function require a test?

@kamilmysliwiec
Copy link
Member

I think no tests are needed in this case.

@kamilmysliwiec
Copy link
Member

Let's track this here #9270

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs triage This issue has not been looked into type: enhancement 🐺
Projects
None yet
Development

No branches or pull requests

2 participants