×ðÁú¿­Ê±¹ÙÍøµÇ¼

laravelÔõôÅжÏÐÐÁÐÊÇ·ñ¿ªÆô

laravel ÊÇÒ»¸öºÜÊÇÊ¢ÐÐµÄ php ¿ª·¢¿ò¼Ü £¬ËüÌṩÁËÐí¶àÀû±ã¿ª·¢µÄ¹¦Ð§¡£ÆäÖÐÖ®Ò»¾ÍÊÇÐÐÁУ¨queue£©ÏµÍ³ £¬¿ÉÒÔ½«ºÄʱµÄʹÃüÒì²½´¦Àí £¬¼õÇáЧÀÍÆ÷µÄ¼ç¸º¡£µ«¹ØÓÚ¿ª·¢ÕßÀ´Ëµ £¬ÓÐʱÐèÒªÅжÏÐÐÁÐÊÇ·ñ¿ªÆô £¬ÒÔ±ã¸üºÃµØ¿ØÖÆ´úÂëÁ÷³Ì¡£

ÔÚ Laravel ÖÐ £¬ÅжÏÐÐÁÐÊÇ·ñ¿ªÆô¿ÉÒÔ·ÖΪÁ½¸öÇéÐÎÀ´ÌÖÂÛ£º

ÅжÏÐÐÁÐÊÇ·ñÒѾ­Æô¶¯

ÈôÊÇÎÒÃÇÔÚʹÓà Laravel µÄʱ¼äÐèÒªÖ´ÐÐÒ»¸öºÄʱµÄʹÃü £¬ÎÒÃÇͨ³£»á½«Õâ¸öʹÃü¼ÓÈëµ½ÐÐÁÐÖÐ £¬È»ºóʹÓà Laravel ÌṩµÄ Artisan ÏÂÁîÀ´Æô¶¯ÐÐÁУº

php artisan queue:work

µÇ¼ºó¸´ÖÆ

»òÕßÊÇʹÓÃÐÐÁмàÌýÆ÷Æô¶¯ÐÐÁУº

php artisan queue:listen

µÇ¼ºó¸´ÖÆ

Õâʱ¼äÈôÊÇÎÒÃÇÒªÅжÏÐÐÁÐÊÇ·ñÒѾ­Æô¶¯ £¬¿ÉÒÔ±àдÒÔÏ´úÂ룺

if (\Illuminate\Support\Facades\Config::get('queue.default') != 'sync' && \Illuminate\Support\Facades\Queue::size()>0) {
    // ÐÐÁÐÒѾ­Æô¶¯ÇÒÐÐÁÐÖÐÓÐÆÚ´ý´¦ÀíµÄʹÃü
} else {
    // ÐÐÁÐδÆô¶¯»òÐÐÁÐÖÐûÓÐÆÚ´ý´¦ÀíµÄʹÃü
}

µÇ¼ºó¸´ÖÆ

ÎÒÃÇÅжÏÁËĬÈÏÐÐÁÐÇý¶¯ÊÇ·ñΪ sync £¬ÈôÊDz»ÊǾÍÒÔΪÐÐÁÐÒѾ­Æô¶¯¡£Í¬Ê± £¬Queue::size() ÒªÁì¿ÉÒÔ»ñÈ¡Ä¿½ñÐÐÁÐÖÐÆÚ´ý´¦ÀíµÄʹÃüÊýÄ¿ £¬ÈôÊÇÊýÄ¿´óÓÚ 0 £¬¾ÍÒÔΪÐÐÁÐÖÐÓÐÆÚ´ý´¦ÀíµÄʹÃü¡£

ÅжÏÐÐÁÐÊÇ·ñ±»½ûÓÃ

ÔÚһЩÌØÊâÇéÐÎÏ £¬ÎÒÃÇÐèÒª½ûÓÃÐÐÁÐϵͳ £¬´ËʱÎÒÃÇ¿ÉÒÔÔÚ .env ÎļþÖн« QUEUE_CONNECTION ÉèÖÃΪ sync£º

QUEUE_CONNECTION=sync

µÇ¼ºó¸´ÖÆ

µ«ÕâÖÖÇéÐÎÏ £¬Queue::size() ÒªÁì»ñÈ¡µ½µÄʹÃüÊýĿʼÖÕΪ 0 £¬ÓÉÓÚ²¢Ã»ÓÐÕæÕýµÄÐÐÁÐÔÚÊÂÇé¡£Õâʱ¼äÈôÊÇÎÒÃÇÒªÅжÏÐÐÁÐÊÇ·ñ½ûÓà £¬¿ÉÒÔ±àдÒÔÏ´úÂ룺

if (\Illuminate\Support\Facades\Config::get('queue.default') == 'sync') {
    // ÐÐÁÐÒѾ­±»½ûÓÃ
} else {
    // ÐÐÁÐδ±»½ûÓÃ
}

µÇ¼ºó¸´ÖÆ

ÎÒÃÇÖ»ÐèÒªÅжÏĬÈÏÐÐÁÐÇý¶¯ÊÇ·ñΪ sync ¼´¿É¡£ÈôÊÇÊÇ £¬¾ÍÌåÏÖÐÐÁб»½ûÓÃÁË¡£

×ܽá

ÒÔÉϾÍÊÇÔÚ Laravel ÖÐÅжÏÐÐÁÐÊÇ·ñ¿ªÆôµÄÒªÁì¡£ÔÚ±àд´úÂëµÄʱ¼ä £¬ÎÒÃÇÐèҪעÖØÐÐÁеÄĬÈÏÇý¶¯ÊÇ·ñΪ sync £¬ÒÔ¼°ÐÐÁÐÖÐÆÚ´ý´¦ÀíµÄʹÃüÊýÄ¿¡£Í¨¹ýÕâЩҪÁì £¬ÎÒÃÇ¿ÉÒÔÔ½·¢×¼È·µØ¿ØÖÆ´úÂëÁ÷³Ì £¬´Ó¶ø¸üºÃµØ¾ÙÐпª·¢¡£

ÒÔÉϾÍÊÇlaravelÔõôÅжÏÐÐÁÐÊÇ·ñ¿ªÆôµÄÏêϸÄÚÈÝ £¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡

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

Ïà¹ØÐÂÎÅ

ÁªÏµ×ðÁú¿­Ê±¹ÙÍøµÇ¼

18523999891

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

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

QR code
ÍøÕ¾µØͼ