Home >Backend Development >PHP Tutorial >Laravel queue database is not operating?

Laravel queue database is not operating?

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-07-06 13:53:061001browse

I turned on listening with the command: php artisan queue:listen
This is the handle method in my job class

<code>public function handle()
    {
        $res1 = DB::table('log')->insertGetId(
            ['op' => 1]
        );
    }</code>

Just insert a piece of data.
Call in controller

<code>class IndexController extends Controller
{
    public function register() {
        $this->dispatch((new ProcessRegister(1))->onQueue('register'));
        echo "下单成功!";
    }
}</code>

The Redis service has been started. After accessing http://localhost/test, I found that there is no data in the database. . .

Reply content:

I turned on listening with the command: php artisan queue:listen
This is the handle method in my job class

<code>public function handle()
    {
        $res1 = DB::table('log')->insertGetId(
            ['op' => 1]
        );
    }</code>

Just insert a piece of data.
Call in controller

<code>class IndexController extends Controller
{
    public function register() {
        $this->dispatch((new ProcessRegister(1))->onQueue('register'));
        echo "下单成功!";
    }
}</code>

The Redis service has been started. After accessing http://localhost/test, I found that there is no data in the database. . .

Added a special group to solve the problem. You should use php artisan queue:listen --queue=register
--queue to listen to the specific queue

It is recommended not to use it

<code>->onQueue('register'))</code>

, then

<code>php artisan queue:listen</code>

Nor add --queue

There are only a few tasks that need to be executed in the background, so there is no need to name them, and if you misspell a word, another weird bug will be created.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn