×ðÁú¿­Ê±

laravelÐÐÁÐʧ°ÜÊÇʲôÇéÐÎ

ÔÚʹÓà laravel ÐÐÁÐʱ £¬ÎÒÃÇ¿ÉÄÜ»áÓöµ½Ê¹ÃüÖ´ÐÐʧ°ÜµÄÇéÐΡ£Õâʱ¼ä £¬laravel ÌṩÁËÒ»¸öºÜºÃµÄ½â¾ö¼Æ»® £¬×ÝÈ»ÓÃʧÁÓÐÐÁС£

ÎÒÃÇÔÚÖ´ÐÐÐÐÁÐʹÃüʱ £¬¿ÉÒÔ½«Ê§°ÜµÄʹÃüÍÆÈëÒ»¸öרÃÅÓÃÀ´´¦Öóͷ£Ê§°ÜʹÃüµÄÐÐÁÐÖÐ £¬È»ºó°´ÆÚ¼ì²éÕâ¸öÐÐÁÐ £¬²¢ÖØÐÂÖ´ÐÐÆäÖеÄʧ°ÜʹÃü¡£ÕâÑùÒ»À´ £¬ÎÒÃǾͿÉÒÔ×èÖ¹ÐÐÁÐʹÃüÒòһЩСÎÊÌâ¶øÖÕÖ¹ £¬¼ÌÐøΪÎÒÃÇЧÀÍ¡£

Laravel µÄʧÁÓÐÐÁÐÌṩÁ˶àÖÖÉèÖÃÒÔ¼°¿ÉÀ©Õ¹µÄ½Ó¿Ú £¬ÎÒÃÇ¿ÉÒÔƾ֤×Ô¼ºµÄÐèÇóÀ´¾ÙÐÐÉèÖá£

Ê×ÏÈ £¬ÎÒÃÇÐèÒªÔÚÉèÖÃÎļþ config/queue.php ÖÐÉèÖÃʧ°ÜµÄʹÃüÓ¦¸Ã½øÈëµÄÐÐÁС£¸ÃÉèÖÃÏîµÄ¼üΪ failed £¬ÆäֵΪһ¸öÊý×é £¬ÆäÖаüÀ¨ driver ºÍ queue Á½¸öÉèÖÃÏî¡£driver ÉèÖÃÏîÌåÏÖÎÒÃÇÏ£ÍûʹÓÃÄĸöʧ°ÜÇý¶¯ £¬Laravel ĬÈÏÌṩÁË database ºÍ redis Á½¸öʧ°ÜÇý¶¯¡£¶ø queue ÔòÌåÏÖʧ°ÜʹÃü½«½øÈëÄĸöÐÐÁС£

'failed' => [
    'driver' => 'database',
    'queue' => 'failed',
],

µÇ¼ºó¸´ÖÆ

ÈôÊÇÎÒÃÇÏ£ÍûʹÓÃÆäËûµÄʧ°ÜÇý¶¯ £¬ÎÒÃÇ¿ÉÒÔͨ¹ý×¢²á×Ô½ç˵ʧ°ÜÇý¶¯²¢ÔÚ driver ÉèÖÃÏîÖÐÒýÓÃËüÀ´ÊµÏÖ¡£

×¢²á×Ô½ç˵Çý¶¯µÄ´úÂëÈçÏÂËùʾ£º

Queue::failing(function ($connection, $job, $data) {
    // ×Ô½ç˵´¦Öóͷ£Âß¼­
});

µÇ¼ºó¸´ÖÆ

½ÓÏÂÀ´ £¬ÎÒÃÇÐèÒª½ç˵´¦Öóͷ£Ê§°ÜʹÃüµÄÏêϸÂß¼­¡£ÎÒÃÇ¿ÉÒÔÖ±½Ó½«Ê§°ÜʹÃüÔÙ´ÎÍÆÈëÐÐÁÐÖÐ £¬ÕâÑùÔÚÏÂÒ»´ÎÐÐÁд¦Öóͷ£Ê±¸ÃʹÃü¾Í»áÔٴα»Ö´ÐС£»òÕß £¬ÎÒÃÇÒ²¿ÉÒÔ½«Ê§°ÜʹÃüµÄһЩÐÅÏ¢´æ´¢ÏÂÀ´ÒÔ±¸ºóÐø¼ì²éÒÔ¼°´¦Öóͷ£¡£

¹ØÓÚ½«Ê§°ÜʹÃüÍÆÈëÐÐÁеĴ¦Öóͷ£·½·¨ £¬ÎÒÃÇ¿ÉÒÔʹÓÃÒÔÏ´úÂ룺

Queue::failing(function ($connection, $job, $data) {
    $queue = $job->getQueue();
    $payload = $job->payload();

    Queue::pushRaw($payload, $queue);
});

µÇ¼ºó¸´ÖÆ

Õâ¶Î´úÂ뽫ʧ°ÜʹÃüÖØÐÂÍƵ½ÁËԭʼÐÐÁÐÖÐ £¬ÆÚ´ýÏÂÒ»´Î±»Ö´ÐС£

¶ø¹ØÓÚ½«Ê§°ÜʹÃüÐÅÏ¢´æ´¢µÄ´¦Öóͷ£·½·¨ £¬ÎÒÃÇ¿ÉÒÔʹÓÃÒÔÏ´úÂ룺

Queue::failing(function ($connection, $job, $data) {
    // ½«Ê§°ÜʹÃüÐÅÏ¢´æ´¢µ½Êý¾Ý¿âÖÐ
    DB::table('failed_jobs')->insert([
        'connection' => $connection,
        'queue' => $job->getQueue(),
        'payload' => $job->getRawBody(),
        'exception' => $data['exception'],
        'failed_at' => now(),
    ]);
});

µÇ¼ºó¸´ÖÆ

Õâ¶Î´úÂ뽫ʧ°ÜʹÃüµÄÐÅÏ¢´æ´¢µ½Êý¾Ý¿â±í failed_jobs ÖÐ £¬ÒÔ±ãÎÒÃÇÉÔºó¾ÙÐмì²éÒÔ¼°´¦Öóͷ£¡£

³ýÁËÒÔÉÏÁ½ÖÖ´¦Öóͷ£·½·¨ £¬Laravel »¹ÌṩÁ˸ü¶àµÄ´¦Öóͷ£·½·¨¹©ÎÒÃÇÑ¡Ôñ¡£ÎÒÃÇ¿ÉÒÔÉó²é Laravel µÄÎĵµÒÔ¼°Ô´´úÂëÒÔÏàʶ¸ü¶àÏêÇé¡£

×îºó £¬ÎÒÃÇÐèÒª°´ÆÚ¼ì²éʧÁÓÐÐÁв¢ÖØÊÔÆäÖеÄʹÃü¡£Laravel ĬÈÏÌṩÁË queue:retry ÏÂÁîÀ´¾ÙÐÐʹÃüÖØÊÔ £¬¸ÃÏÂÁî½ÓÊÜÒ»¸ö¿ÉÑ¡²ÎÊý –queue £¬ÌåÏÖÎÒÃÇÒªÖØÊÔµÄʹÃüÐÐÁС£ÈôÊDz»Ö¸¶¨¸Ã²ÎÊý £¬ÔòĬÈÏÖØÊÔËùÓÐÐÐÁС£

php artisan queue:retry 5 --queue=my-queue

µÇ¼ºó¸´ÖÆ

¸ÃÏÂÁ»á´ÓʧÁÓÐÐÁÐÖÐµÄ my-queue ÐÐÁÐÖÐÖØÐÂÖ´ÐÐÇ° 5 ¸öʧ°ÜʹÃü¡£

³ý´ËÖ®Íâ £¬ÎÒÃÇ»¹¿ÉÒÔʹÓòÙ×÷ϵͳµÄ׼ʱʹÃü¹¤¾ß£¨Èç crontab£©À´ÖÜÆÚÐÔµØÖ´ÐÐ queue:retry ÏÂÁî £¬ÒÔ°´ÆÚ´¦Öóͷ£Ê§°ÜʹÃü¡£

×ÜÖ® £¬Laravel µÄʧÁÓÐÐÁÐÌṩÁËÒ»¸öºÜÊǺÃÓõĽâ¾ö¼Æ»®À´´¦Öóͷ£ÐÐÁÐʹÃüµÄʧ°ÜÇéÐΡ£ÎÒÃÇ¿ÉÒÔƾ֤×Ô¼ºµÄÐèÇó¾ÙÐÐÉèÖà £¬²¢¶Ôʧ°ÜʹÃü¾ÙÐжàÖÖ²î±ðµÄ´¦Öóͷ£·½·¨¡£Í¬Ê± £¬ÎÒÃÇ»¹ÐèÒª°´ÆÚ¼ì²éʧÁÓÐÐÁв¢ÖØÊÔÆäÖеÄʹÃü £¬ÒÔÈ·±£ÐÐÁÐʹÃüÄܹ»Õý³£µØÔËÐС£

Ï£Íû±¾ÎĶԸ÷ÈËÓÐËù×ÊÖú¡£

ÒÔÉϾÍÊÇlaravelÐÐÁÐʧ°ÜÊÇʲôÇéÐεÄÏêϸÄÚÈÝ £¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡

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

Ïà¹ØÐÂÎÅ

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

18523999891

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

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

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