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

VPBram's avatar

Queued Job not dispatching from within Kafka Listener

Hello fellow Laravel devs

I'm experiencing a pretty weird issue. I have a job called AnalyticsEventProcessingJob which accepts a $uuid string parameter. This job is dispatched from within a Kafka listener function.

The listener function captures incoming Kafka messages into an array , and when 10.000 messages have been received it writes some data to a database and then dispatches the job like this :

        AnalyticsEventProcessingJob::dispatch($this->batchId)->onQueue('email_event_tracking');

I see the data being inserted in the database fine, but the job is never dispatched onto Horizon. However, when I create a testroute :

     Route::get('analyticseventjob','App\Http\Controllers\ApiController@analyticseventjob');

which does exactly the same dispatch command, it works fine when the route is called.

I don't get any exceptions/errors, it's simply as if this code in the listener just doesn't do anything. Any suggestions on where I could start debugging/finetuning this ?

PS the Laravel app is deployed on HashiCorp/Nomad

0 likes
1 reply
VPBram's avatar

I should have posted sooner , as I already found the issue :-) Just posting here for future devs who might encounter the same issue.

In the YAML file for the Nomad deployment the .ENV variable was set to QUEUE_CONNECTION: database

So they were all appearing in the database jobs table instead of Redis/Horizon

Please or to participate in this conversation.