laravel / horizon

Dashboard and code-driven configuration for Laravel queues.
https://laravel.com/docs/horizon
MIT License
3.84k stars 645 forks source link

dispatch job only triggered when other dispatch is called. #1491

Closed singleseeker closed 3 weeks ago

singleseeker commented 3 weeks ago

Horizon Version

5.27.1

Laravel Version

10.39.0

PHP Version

8.2.22

Redis Driver

PhpRedis

Redis Version

6.0.2

Database Driver & Version

No response

Description

I have a Job.

<?php

namespace App\Jobs;

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

class SimpleJob implements ShouldQueue
{

    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;

    protected $message;

    /**
     * Create a new job instance.
     *
     * @return void
     */
    public function __construct($message = "Default message")
    {
        $this->message = $message;
    }

    /**
     * Execute the job.
     *
     * @return void
     */
    public function handle()
    {
        Log::info("SimpleJob executed with message: " . $this->message);

        echo "SimpleJob executed with message: " . $this->message . "\n";
    }
}

And when I use tinker to debug

dispatch(new App\Jobs\SimpleJob("Delayed Job!"));

It didn't run at all until the next time I called dispatch.

Steps To Reproduce

image
yangjisen commented 3 weeks ago

I also encountered the same situation

singleseeker commented 3 weeks ago

@driesvints you've time to have a look? It's weird. Hope to get your help.

driesvints commented 3 weeks ago

Hi there,

Thanks for reporting but it looks like this is a question which can be asked on a support channel. Please only use this issue tracker for reporting bugs with the library itself. If you have a question on how to use functionality provided by this repo you can try one of the following channels:

However, this issue will not be locked and everyone is still free to discuss solutions to your problem!

Thanks.