laravellaravel-8jobs

Laravel's console command: dispatchSync is not sync


Context: Laravel 8 webapp and console command running on debian 11 wit php 7.4

I've a job dispatched by events and listeners and so on when user is using our webapp.

To test and for scheduled purposes we have also a console command that is dispatching the same job, but using dispatchSync

\App\Jobs\CardoExport::dispatchSync($buyer_id, $job_config_name);

The problem is that is not really sync. If I run the console command from the shell, the job is being dispatched and then executed only if I have a queue worker/listener running.

Why !?

Am I misunderstuding something?


Solution

  • I found the answer

    My Job class is implementing the ShouldQueue empty interface

    Removing this, the dispatchSync is executed as expected.