ksassnowski/venture

Is Venture compatible with Laravel's job middleware?

Opened this issue ยท 4 comments

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.

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?

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

@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. ๐Ÿค”

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.