-
-
Notifications
You must be signed in to change notification settings - Fork 7.7k
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
Kafka commitOffsets #9283
Comments
What's the difference between this approach and the default behavior when
Sounds good. Would you like to create a PR for this issue? @davidschuette |
I have to do more investigation but I think kafkajs commits offsets regardless of the result of the callback (e.g. commits offset even though callback threw error). I will create a PR for the this issue. For now just for the |
Provide access to kafkajs commitOffset by using @ctx() decorator when handeling an event. This commit closes Kafka commitOffsets nestjs#9283.
Error thrown by event handling method are no longer being caught by RcpExecptionFilter. Instead errors are passed to kafkajs's eachMessage. This results in proper interaction with kafka. This commit closes Kafka commitOffsets nestjs#9283.
After doing more investigation, I determined that the catching of errors in |
Let's track this here #9293 |
As a (very late) follow-up to this, I think there is still value for having a If that is still valuable, I'm open to making a PR to add that utility method. |
Is there an existing issue that is already proposing this?
Is your feature request related to a problem? Please describe it
I tried implementing the new
commitOffsets
function ofClientKafka
, I added. This is when I realized that the instance ofClientKafka
that will be injected, is only used for producing not consuming messages. As a result theconsumer
prop isundefined
and cannot be used to commit offsets.To properly use the
commitOffsets
function of a consumer, access toServerKafka
is needed which is used when connecting or creating a microservice inmain.ts
.Describe the solution you'd like
I have thought of two other options to provide access to
commitOffsets
.@Ctx()
decorator.main.ts
This would await the callback that is provided by the
@EventPattern('topic')
decorator and then commit the offset automatically without any additional logic needed.The example from 1. could be simplified as follows:
Teachability, documentation, adoption, migration strategy
This enables a simple but still flexible approach to commit offsets when working with kafka.
What is the motivation / use case for changing the behavior?
The implementation I previously offered did not meet my expectations.
The text was updated successfully, but these errors were encountered: