Skip to content

laravel Queue not create job on mongodb collection #2015

Open
@mean-cj

Description

@mean-cj
  • Laravel 7.5
  • Laravel-mongodb Version: 3.6.3
  • PHP Version: 7.4.4
  • Database Driver & Version: 4.2

Description:

After run the method "CLASS::dispatch()" job is not exists or create on jobs collection.

config\app.php

   'providers' => [
      Jenssegers\Mongodb\MongodbServiceProvider::class,
      Jenssegers\Mongodb\MongodbQueueServiceProvider::class,
    ]

config\queue.php

return [
   'default' => env('QUEUE_CONNECTION', 'database'),
   'connections' => [
      'database' => [
         'driver' => 'mongodb',
         'table' => 'jobs',
         'queue' => 'default',
         'expire' => 60,   
      ],
    ]
   'failed' => [
      'driver' => env('QUEUE_FAILED_DRIVER', 'database'),
      'database' => env('DB_CONNECTION', 'mongodb'),
      'table' => 'failed_jobs',
   ],

\app\Jobs\TestJob.php

<?php

namespace App\Jobs;

use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
use Illuminate\Support\Facades\Http;

class TestJob implements ShouldQueue
{
   use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;

   protected $data;
   public function __construct($data)
   {
      $this->data = $data;
   }

   public function handle()
   {
     ...
   }
}

Step 1 : call dispatch() method, it not work , job not exists or create on jobs collection
TestJob::dispatch($data);

Step 2 : it work , job created on jobs collection
TestJob::dispatch($data)->onConnection('database')

Step 3 : it work, job created.

class TestJob implements ShouldQueue
{
   use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;

   public function __construct($data)
   {
      $this->connection = 'database';
   }
  ...
}

Thank you.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions