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

Laravel queue database is not operating?

WBOY
Release: 2016-07-06 13:53:06
Original
994 people have browsed it

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>
Copy after login
Copy after login

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>
Copy after login
Copy after login

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>
Copy after login
Copy after login

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>
Copy after login
Copy after login

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>
Copy after login

, then

<code>php artisan queue:listen</code>
Copy after login

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.

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template