Skip to content

Fix: KafkaConsumer.commitSync should not block #68

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

Conversation

felixschlegel
Copy link
Contributor

@felixschlegel felixschlegel commented Jun 22, 2023

Info: This PR sits on top of #66

Motivation

Currently our invocation to rd_kafka_commit inside of
KafkaCosumer.commitSync is blocking a cooperative thread.
This PR aims to make KafkaCosumer.commitSync non-blocking by using the
callback-based commit API.

Modifications:

  • move commitSync logic to KafkaClient
  • replace the blocking invocation to rd_kafka_commit with a callback-based invocation to rd_kafka_commit_queue
    which is then wrapped inside a withAsyncThrowingContinuation statement

@felixschlegel felixschlegel force-pushed the fs-kafka-commit-sync-stop-blocking branch from 8ded307 to 36f22ba Compare June 27, 2023 09:21
@felixschlegel felixschlegel force-pushed the fs-kafka-commit-sync-stop-blocking branch from 36f22ba to 2bd1639 Compare June 28, 2023 17:26
Motivation:

Currently our invocation to `rd_kafka_commit` inside of
`KafkaCosumer.commitSync` is blocking a cooperative thread.
This PR aims to make `KafkaCosumer.commitSync` non-blocking by using the
callback-based commit API.

Modifications:

* move `commitSync` logic to `KafkaClient`
* replace the blocking invocation to
  [rd_kafka_commit](https://docs.confluent.io/platform/current/clients/librdkafka/html/rdkafka_8h.html#ab96539928328f14c3c9177ea0c896c87)
  with a callback-based invocation to
  [rd_kafka_commit_queue](https://docs.confluent.io/platform/current/clients/librdkafka/html/rdkafka_8h.html#af76a6a73baa9c2621536e3f6882a3c1a)
  which is then wrapped inside a `withAsyncThrowingContinuation` statement
@felixschlegel felixschlegel force-pushed the fs-kafka-commit-sync-stop-blocking branch from 2bd1639 to 92fce97 Compare June 30, 2023 11:14
@felixschlegel
Copy link
Contributor Author

Implemented in #73 , closing PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant