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

Is Venture compatible with Laravel's job middleware? #88

Open
tristanjahier opened this issue Oct 27, 2023 · 4 comments
Open

Is Venture compatible with Laravel's job middleware? #88

tristanjahier opened this issue Oct 27, 2023 · 4 comments

Comments

@tristanjahier
Copy link

tristanjahier commented Oct 27, 2023

Hello! 👋🏻

I am dispatching a lot of jobs inside a workflow. To avoid race conditions and overload, I want to prevent overlap of jobs that work on the same resource (let's say an external database). I have tried to set the WithoutOverlapping middleware on the job (see Laravel docs), but it does not seem to work as intended.

I have put a debug log inside the middleware() method of the job, and it never gets called when dispatched from inside the workflow. However, if I dispatch manually the job on its own, the method is called (the debug log shows up).

It seems to show that job middleware is ignored when used in a workflow.

@ksassnowski
Copy link
Owner

ksassnowski commented Oct 27, 2023

I'm unable to reproduce this. Can you set up a small repository that illustrates the bug? What queue connection are you using and how are you starting the workflow?

@tristanjahier
Copy link
Author

tristanjahier commented Oct 27, 2023

I am using Redis, and I am starting the workflow using the instance method run(). And the queue is handled by Laravel Horizon.

@tristanjahier
Copy link
Author

@ksassnowski oddly enough, making my workflow job implement Sassnowski\Venture\WorkflowableJob (instead of relying only on Illuminate\Contracts\Queue\ShouldQueue and the WorkflowStep trait) made things work as intended. 🤔

@ksassnowski
Copy link
Owner

Yes, all jobs in a workflow should implement this interface. Jobs that don't implement the interface are deprecated and are only kept around for BC reasons support for them will be dropped in the next major version. What you are describing sounds like a bug in the adapter Venture internally uses to wrap jobs that don't implement the interface.

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

No branches or pull requests

2 participants