尊龙凯时人生就是搏

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¡¢ÍøÕ¾µØͼ