-
Notifications
You must be signed in to change notification settings - Fork 120
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
@JobWorker's default autoCompletion can lead to problems #286
Comments
💡 You could pass in a decorated ZeebeClient that does something special when trying to complete the job explicitly, e.g. throw an exception or log a specialized warning with clear instructions. |
I do something similar in the C# client, using a wrapper and not complete the job if it was completed before https://github.com/camunda-community-hub/zeebe-client-csharp/blob/main/Client/Impl/Worker/JobWorker.cs#L231 |
Ping @falko |
I prefer Zelldon's approach. It is: "let the user complete the job when and where they want, and if they don't, do it for them". Versus having it tell them: "I decide when to complete the job, human". For the Node.js client, if the user tries to complete the job twice, or complete then fail the job, or some combination of signal multiple outcomes for the same job, I produce an error that warns them that the logic in their handler is faulty. I also made it so that you have to return some job acknowledgement method response from the job handler, to get linting for all code paths that they handled it explicitly. I chose that over auto-completing in the Node client to make it explicit. But since we have auto-completing in this client - if the user manually completes the job, they didn't do anything wrong, so we shouldn't throw an error, IMO. |
I like that approach. For completeness, that should also mean: if they fail the job or throw an error on the job manually, don't complete the job for them |
Nothing explicitly warns users to avoid completing jobs when
autoCompletion
is enabled.We should clarify the that exists warning and instruct the user how to resolve the problem.
Why?
Recently, we've seen a few situations where users use the new
@JobWorker
annotation. This annotation defaults to auto-completing the jobs. Some users may not be aware of this and explicitly complete the job.When this happens, a warning is logged by the auto-completion logic:
This warning makes sense but is only helpful for users that are aware of the auto-completion mechanics.
Completing the job twice does not have to be a problem, but it can be when the job is completed asynchronously and with variables. In that case, the explicit job-completion is racing the auto-completion.
The text was updated successfully, but these errors were encountered: