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

onComplete alternative #517

Open
lramirez925 opened this issue Oct 19, 2024 · 3 comments
Open

onComplete alternative #517

lramirez925 opened this issue Oct 19, 2024 · 3 comments

Comments

@lramirez925
Copy link

Looking at upgrading to v10, but having issues wrapping my head around how to replace my onComplete scenario. Is that flow no longer supported at all going forward or am I just blind?

Currently I have workflow system that adds an "onComplete" that looks up the next job to run and schedules it. I prefer to have it separate from the actual job code. Just making sure I am not missing a new similar flow that I could use before rebuilding it.

@timgit
Copy link
Owner

timgit commented Oct 20, 2024

onComplete was removed in v10 and I'm not currently planning on bringing them back. Dead letter queues handle the majority use case of orchestration of the failure completion state.

@lramirez925
Copy link
Author

lramirez925 commented Oct 21, 2024

You mention dead letter queues but that would only be able to handle performing actions when jobs fail correct?

So there isn't any way to handle successful job lifecycles on a queue in any way for the foreseeable future?

@eric-gonzalez-tfs
Copy link

You mention dead letter queues but that would only be able to handle performing actions when jobs fail correct?

So there isn't any way to handle successful job lifecycles on a queue in any way for the foreseeable future?

@lramirez925 - I also needed this functionality and implemented a workaround. My goal was to track the success, failure, and retry metrics for each of my jobs.

To achieve this, I created a wrapper function that surrounds each job before instantiation. This wrapper awaits the execution of the actual job handler, catching and re-throwing any errors that occur to retain pg-boss error handling functionality.

Depending on the outcome (success or error), the wrapper then creates a new job dedicated to monitoring the job state.

From my experience, while pg-boss DLQs are effective for handling failed jobs, they fall short in tracking successful and retried jobs. An onComplete alternative would be very useful for this purpose.

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

No branches or pull requests

3 participants