4

Hi there seems to be a problem with my queue on laravel homestead. Work and Listen processes 1 queue at a time is there any way to make run it once and processes all the queue in the jobs table?

enter image description here

Here is my code:

DB::beginTransaction();
    try {
        $model_data = $this->transformCsvDataToModelData($this->csv_data, $this->data['file_columns'], $this->data['table_columns'], $this->data);
        $dynamic_list_model = new DynamicDataList();
        $dynamic_list_model->setTable($this->list->table_name);
        $dynamic_list_model->insert($model_data);
        $this->notify($this->data['user']->id, [
            'title' => 'Data list upload successful',
            'message' => 'Batch ' . ($this->index + 1) . ' data list upload done.'
        ], 'success');
        DB::commit();
    } catch (Exception $exception) {
        DB::rollBack();
    }
  • Why `--queue=data_list_upload` ? Do you mean, each time you run `php artisan queue:work` it process 1 Queue and then the command stop so you have to run it again? So why `App\Events\DataListUploadJob` and `App\Events\Notify` are being both process? Normally it should stick to the process and wait for new queues to arrive to process them. May be you could tell us more from your workflow, when and how user upload data list. – KeitelDOG Dec 16 '18 at 15:29
  • the Notify event is using ShouldBroadcastNow because I want to notify the user once a certain action is done/completed I tried removing ShouldBroadcastNow but still it did not fix. Even in queue:listen it also processes only 1 job. Basically the workflow is when the user uploads a data then it chunks it by a certain amount then by chunk it creates a queue to upload it in db and once that batch is done it notify the user that the first batch is finished uploading. – Keannu Alforque Atilano Dec 17 '18 at 18:33
  • What version of Laravel is this? – Travis Britz Dec 18 '18 at 19:26
  • The latest one 5.7 I think. – Keannu Alforque Atilano Dec 19 '18 at 14:12
  • Would you mind sharing how you are dispatching your Jobs? Also the full code from App\Events\DataListUploadJob and App\Events\Notify would come in handy. – Jorge Rodríguez Dec 19 '18 at 19:27
  • Maybe not related with the question, but try throwing the exception again inside the catch block. Laravel uses the exceptions to fail the job. – Taha Paksu Dec 21 '18 at 08:20

2 Answers2

0

If you are using supervisor to manage the queue worker,

configure numprocs=8

In this example, the numprocs directive will instruct Supervisor to run 8 queue:work processes and monitor all of them.

Here is the more info about it, https://laravel.com/docs/5.7/queues#supervisor-configuration

  • I'm not using supervisor only the php artisan queue:listen and php artisan queue:work but none of those watches the queues it only processes it 1 by 1 I have to manually run the command for the command to process the next queue. – Keannu Alforque Atilano Dec 14 '18 at 13:23
0

I had this issue a few days ago, The problem was a server error, Which wasn't notifying me that where the issue is. Your queue is working fine, It fails when an error occurs in your code. Means that your first event runs fine but for the second one it fails.

Try debugging your business logic not your queue, Its not an issue of Homestead either.

Let us know.

Gammer
  • 5,453
  • 20
  • 78
  • 121