×ðÁú¿­Ê±

laravelÐÐÁзַ¢²»½øÔõô°ì

ÔÚlaravel¿ª·¢ÖУ¬Ê¹ÃüÐÐÁÐÊÇÒ»¸öºÜÊÇÖ÷ÒªµÄ×é¼þ£¬Ëü¿ÉÒÔÈÃÎÒÃǽ«Ò»Ð©ºÄʱµÄ²Ù×÷Òì²½Ö´ÐУ¬¶ø²»»áÓ°Ïìµ½Óû§µÄÌåÑé¡£laravelÖеÄʹÃüÐÐÁзÖΪÁ½¸ö²¿·Ö£ºÊ¹Ãü·Ö·¢ºÍʹÃüÖ´ÐС£ËäÈ»ÔÚÀíÂÛÉÏʹÃü·Ö·¢Ó¦¸ÃÊǺܼòÆӵģ¬µ«ÓÐʱ¼äÎÒÃÇ»áÓöµ½Ò»Ð©ÎÊÌ⣬ºÃ±ÈʹÃü·Ö·¢²»½ø£¬Õâʱ¼ä¸ÃÔõô°ìÄØ£¿

Ê×ÏÈ£¬ÎÒÃÇÐèҪȷ¶¨Ê¹Ãü·Ö·¢ÊÇ·ñÀֳɡ£LaravelµÄʹÃü·Ö·¢ÊÇͨ¹ýÐÐÁÐÀ´ÊµÏֵģ¬ÎÒÃÇ¿ÉÒÔͨ¹ýÉó²éÐÐÁеÄ״̬À´È·¶¨Ê¹ÃüÊÇ·ñÒѾ­±»·Ö·¢¡£LaravelÌṩÁËÒ»¸öÏÂÁîÀ´¼ì²éÐÐÁеÄ״̬£¬¿ÉÒÔÔÚÖÕ¶ËÖÐÊäÈëÈçÏÂÏÂÁ

php artisan queue:work --status

µÇ¼ºó¸´ÖÆ

Ö´ÐÐÍê±Ïºó£¬ÎÒÃÇ¿ÉÒÔ¿´µ½ÀàËÆÒÔϵÄÊä³ö£º

Status check starting...
The "database" queue has 0 jobs processing.
The "redis" queue is not available.
Written jobs:
- Job 123 on connection "database"
- Job 456 on connection "redis"
- Job 789 on connection "redis"
...

µÇ¼ºó¸´ÖÆ

Õâ¸öÏÂÁî»áÊä³öËùÓÐÐÐÁеÄ״̬£¬°üÀ¨ÕýÔÚ´¦Öóͷ£µÄʹÃüºÍÆÚ´ý´¦Öóͷ£µÄʹÃü¡£ÎÒÃÇÐèҪעÖصÄÊÇ£¬ÔÚLaravelÖÐʹÃü²¢²»ÊÇÁ¬Ã¦Ö´ÐеÄ£¬¶øÊÇÐèÒªÆÚ´ýÐÐÁÐÖеÄʹÃüÖ´ÐÐÆ÷£¨worker£©À´´¦Öóͷ£¡£Òò´Ë£¬×ÝȻʹÃüÒѾ­±»ÀÖÒòËØ·¢µ½ÐÐÁÐÖУ¬ÎÒÃÇÒ²ÐèÒªÆÚ´ýÒ»¶Îʱ¼ä²Å»ª¿´µ½Ëü±»´¦Öóͷ£µÄÇéÐΡ£

ÄÇô£¬ÈôÊÇÎÒÃÇÒѾ­È·¶¨Ê¹Ãü·Ö·¢Àֳɣ¬µ«Ê¹ÃüÕÕ¾ÉûÓб»Ö´ÐУ¬Õâʱ¼äÓ¦¸ÃÔõô°ìÄØ£¿ÏÂÃæÊÇһЩ¿ÉÄܵĽâ¾öÒªÁ죺

¼ì²éÐÐÁÐÇý¶¯

LaravelÖ§³Ö¶àÖÖ²î±ðµÄÐÐÁÐÇý¶¯£¬°üÀ¨Redis¡¢MySQL¡¢BeanstalkdµÈ¡£ÈôÊÇÄãʹÓõÄÊÇRedis»òMySQL×÷ΪÐÐÁÐÇý¶¯£¬ÄÇôÐèҪȷ±£ËüÃÇÒѾ­×¼È·ÉèÖ㬲¢ÇÒÄܹ»Õý³£µØÊÂÇé¡£

ÏêϸÀ´Ëµ£¬ÎÒÃÇÐèÒª¼ì²éLaravelÉèÖÃÎļþÖеÄÐÐÁв¿·Ö£º

'connections' => [

    'sync' => [
        'driver' => 'sync',
    ],

    'database' => [
        'driver' => 'database',
        'table' => 'jobs',
        'queue' => 'default',
        'retry_after' => 90,
    ],

    'beanstalkd' => [
        'driver' => 'beanstalkd',
        'host' => 'localhost',
        'queue' => 'default',
        'retry_after' => 90,
        'block_for' => 0,
    ],

    'redis' => [
        'driver' => 'redis',
        'connection' => 'default',
        'queue' => 'default',
        'retry_after' => 90,
        'block_for' => null,
    ],

],

'default' => env('QUEUE_CONNECTION', 'sync'),

µÇ¼ºó¸´ÖÆ

ÔÚÕâ¸öÉèÖÃÎļþÖУ¬ÎÒÃÇÐèҪȷ±£ÅþÁ¬ÐÅÏ¢ºÍÐÐÁÐÐÅÏ¢¶¼ÒѾ­×¼È·µØÉèÖá£ÈôÊÇûÓÐ׼ȷÉèÖã¬ÄÇôʹÃüÐÐÁоÍÎÞ·¨ÊÂÇé¡£

¼ì²éÐÐÁÐʹÃü

ÈôÊÇÐÐÁÐÒѾ­×¼È·ÉèÖ㬲¢ÇÒʹÃüÈÔȻûÓб»Ö´ÐУ¬ÄÇôÎÒÃÇÐèÒª¼ì²éÐÐÁÐÖеÄʹÃüÊÇ·ñÓÐÎÊÌâ¡£ÏêϸÀ´Ëµ£¬ÎÒÃÇÐèÒª¼ì²éʹÃüÀàÊÇ·ñÒѾ­½ç˵£¬Ê¹ÃüÒªÁìÊÇ·ñÒѾ­ÊµÏÖ£¬ÒÔ¼°Ê¹Ãü²ÎÊýÊÇ·ñÒѾ­×¼È·×ª´ï¡£

ÏÂÃæÊÇÒ»¸ö¼òÆÓµÄʹÃüÀà½ç˵£º

<?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;

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

    /**
     * Create a new job instance.
     *
     * @return void
     */
    public function __construct()
    {
        //
    }

    /**
     * Execute the job.
     *
     * @return void
     */
    public function handle()
    {
        //
    }
}

µÇ¼ºó¸´ÖÆ

ÔÚÕâ¸öʹÃüÀàÖУ¬ÎÒÃǽç˵ÁËÒ»¸öSendEmailʹÃü£¬ËüʵÏÖÁËShouldQueue½Ó¿Ú²¢ÇÒ½ç˵ÁËÒ»¸öhandle()ÒªÁ죬Õâ¸öÒªÌå»áÔÚʹÃü±»Ö´ÐеÄʱ¼ä±»Å²Óá£ÈôÊÇÕâ¸öʹÃüÀàÒѾ­×¼È·µØ½ç˵£¬µ«Ê¹ÃüÈÔȻûÓб»Ö´ÐУ¬ÄÇôÎÒÃÇÐèÒª¼ì²éhandle()ÒªÁìÖеĴúÂëÊÇ·ñÓÐÎÊÌâ¡£

¼ì²éʹÃüÖ´ÐÐÆ÷

ÈôÊÇÐÐÁкÍʹÃü¶¼Ã»ÓÐÎÊÌ⣬ÄÇô¿ÉÄÜÊÇʹÃüÖ´ÐÐÆ÷·ºÆðÁËÎÊÌâ¡£LaravelÖеÄʹÃüÖ´ÐÐÆ÷ͨ¹ýqueue:workÏÂÁîÀ´Æô¶¯£¬ÎÒÃÇ¿ÉÒÔÔÚÖÕ¶ËÖÐÊäÈëÈçÏÂÏÂÁîÀ´Æô¶¯Ê¹ÃüÖ´ÐÐÆ÷£º

php artisan queue:work

µÇ¼ºó¸´ÖÆ

ÈôÊÇʹÃüÖ´ÐÐÆ÷ûÓÐÕý³£ÔËÐУ¬ÄÇôÎÒÃÇÐèÒª¼ì²éÒ»ÏÂÈÕÖ¾Îļþ£¬¿´¿´ÊÇ·ñÓÐÏà¹ØµÄ¹ýʧÐÅÏ¢¡£LaravelµÄÈÕÖ¾ÎļþĬÈÏ´æ´¢ÔÚstorage/logsĿ¼Ï£¬ÎÒÃÇ¿ÉÒÔ·­¿ª×îеÄÈÕÖ¾ÎļþÀ´Éó²é¡£

ʹÓÃÆäËûÐÐÁÐʹÃüÇý¶¯

ÈôÊÇÒÔÉϽâ¾öÒªÁ춼ûÓÐÆð×÷Óã¬ÄÇôÎÒÃÇ¿ÉÒÔʵÑéʹÓÃÆäËûµÄÐÐÁÐʹÃüÇý¶¯À´¿´¿´ÊÇ·ñÄܽâ¾öÎÊÌâ¡£ºÃ±È£¬ÈôÊÇ֮ǰÊÇʹÓÃRedis×÷ΪÐÐÁÐʹÃüÇý¶¯£¬ÄÇôÎÒÃÇ¿ÉÒÔʵÑéʹÓÃMySQL»òBeanstalkdÀ´Ìæ»»¿´¿´¡£

ÔÚLaravelÖУ¬ÎÒÃÇ¿ÉÒÔºÜÈÝÒ׵ظüתҵÁÐʹÃüÇý¶¯¡£Ö»ÐèÒªÐÞ¸ÄLaravelÉèÖÃÎļþÖеÄÐÐÁÐÇý¶¯ÐÅÏ¢¾Í¿ÉÒÔÁË¡£

×ܽáÀ´Ëµ£¬ÔÚÓöµ½LaravelÐÐÁзַ¢²»½øµÄÎÊÌâʱ£¬ÎÒÃÇÐèÒªÏÈÈ·¶¨Ê¹ÃüÊÇ·ñÒѾ­ÀÖÒòËØ·¢µ½ÐÐÁÐÖУ¬È»ºóÔÙÖð²½ÅŲéÐÐÁÐÇý¶¯¡¢ÐÐÁÐʹÃü¡¢Ê¹ÃüÖ´ÐÐÆ÷µÈ·½ÃæµÄÎÊÌ⣬ֱµ½ÕÒµ½½â¾öÒªÁìΪֹ¡£

ÒÔÉϾÍÊÇlaravelÐÐÁзַ¢²»½øÔõô°ìµÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡

ÃâÔð˵Ã÷£ºÒÔÉÏչʾÄÚÈÝȪԴÓÚÏàÖúýÌå¡¢ÆóÒµ»ú¹¹¡¢ÍøÓÑÌṩ»òÍøÂçÍøÂçÕûÀí£¬°æȨÕùÒéÓë±¾Õ¾Î޹أ¬ÎÄÕÂÉæ¼°¿´·¨Óë¿´·¨²»´ú±í×ðÁú¿­Ê±ÂËÓÍ»úÍø¹Ù·½Ì¬¶È£¬Çë¶ÁÕß½ö×ö²Î¿¼¡£±¾ÎĽӴýתÔØ£¬×ªÔØÇë˵Ã÷À´ÓÉ¡£ÈôÄúÒÔΪ±¾ÎÄÇÖÕ¼ÁËÄúµÄ°æȨÐÅÏ¢£¬»òÄú·¢Ã÷¸ÃÄÚÈÝÓÐÈκÎÉæ¼°ÓÐÎ¥¹«µÂ¡¢Ã°·¸Ö´·¨µÈÎ¥·¨ÐÅÏ¢£¬ÇëÄúÁ¬Ã¦ÁªÏµ×ðÁú¿­Ê±ÊµÊ±ÐÞÕý»òɾ³ý¡£

Ïà¹ØÐÂÎÅ

ÁªÏµ×ðÁú¿­Ê±

13452372176

¿É΢ÐÅÔÚÏß×Éѯ

ÊÂÇéʱ¼ä£ºÖÜÒ»ÖÁÖÜÎ壬9:30-18:30£¬½ÚãåÈÕÐÝÏ¢

QR code
¡¾ÍøÕ¾µØͼ¡¿¡¾sitemap¡¿