pilat
156
1
Laravel

How to make sure/check if a Listener is not queued?

Posted 2 years ago by pilat

I need certain listeners to run in "Sync" mode. So that all the data they produce become available to the "client code" immediately after the event were dispatched.

Client code example:

event(new LeadsSynced($payload));

// here I start using something one of listeners produced:
$activities = Activities::where(/* ... */)->all(); 

Listener code:

namespace App\Listeners;

use App\Events\LeadsSynced;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Support\Facades\Log;

class SyncActivities // notice that I don't have "implements ShouldQueue" here
{
//

It looks, however, that the data, which is supposed to be generated by SyncActivities is not available to my client code in the place where I suppose it should be.

Do I miss some other places where it could "go parallel"?

Please sign in or create an account to participate in this conversation.