Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

automica's avatar

Can't get Listener with ShouldQueue to be processed by Queue

I have csv file that I need to process that takes a long time (could be up to 2000 rows of data)

My process:

  1. a user uploads this csv
  2. I validate it has correct columns and valid data in each row
  3. This data is transformed into an object and sent to an external api endpoint
  4. Once processing is complete I want to send an email back to client with success or failure messages in it.

Currently I have handled part 3 and 4 by creating an event, and a listener for this event. The listener, makes the api call (3), and then when that responds I send a notification.

I can see in docs[1] I should be able to add implements ShouldQueue to listener to get it to use a queue. I can see (by logging) that if I do that, can see the event being triggered without the listener being called (which seems expected behaviour). The issue is that I can’t seem to get my application to process the queue.

I have set up the queue to use redis and can see I can add a job to a queue using this example:

Route::get('/test-queue', function () {
    return Queue::push('LogMessage', ['message' => 'Time: ' . time()]);
});

class LogMessage
{
    public function fire($job, $date)
    {
        File::append(app_path() . '/queue.txt', $date['message'] . PHP_EOL);
        sleep(10);
        $job->delete();
    }
}

I can see it being processed if I run php artisan queue:listen

But for the Listener I can’t replicate this behaviour.

I could obviously swap out the event / listener in favour of pushing job to queue but it feels like it should work as it currently does.

Anyone have any recommendation for how to deal with this?

[1] https://laravel.com/docs/5.8/events#queued-event-listeners

0 likes
1 reply

Please or to participate in this conversation.