dongyoucha0645 2017-04-19 19:11
浏览 114
已采纳

当消息发送回SQS时,Laravel队列工作程序作业失败

I have set up my Laravel application to retrieve messages from an SQS queue. Everything works fine during normal operation: Messages are added to the queue when a queueable job is dispatched, and the queue worker grabs the message from SQS and runs the job successfully.

However, I run into problems whenever I use the "View Messages" feature in the SQS web console. Here are the steps to reproduce:

  • Go into the SQS web console
  • Select the queue
  • Run "View Messages" to get a live view of messages coming in
  • After a while, stop polling
  • Messages that were being intercepted are now released
  • Queue worker grabs the messages but they all end up as failed jobs
  • Run artisan queue:retry all
  • Failed jobs now run successfully

Why is this happening? I'm running Laravel 5.2.41 on PHP 5.6.

  • 写回答

1条回答 默认 最新

  • dsgdhtr_43654 2018-05-08 20:25
    关注

    I figured out what was happening:

    • When messages are "intercepted" to be shown in the live view, they are taken out of the queue.
    • When you close the live view, the messages are re-added to the queue. The message metadata is then updated with the number of times the message has been received.
    • Since my queue worker was set to only retry once, then at this point the message has exceeded the number of retries (aka times received) and it marks the job as failed.

    To solve this, I added an extra retry "buffer" to my queue workers:

    php artisan queue:work redis --tries=3
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 求差集那个函数有问题,有无佬可以解决
  • ¥15 【提问】基于Invest的水源涵养
  • ¥20 微信网友居然可以通过vx号找到我绑的手机号
  • ¥15 寻一个支付宝扫码远程授权登录的软件助手app
  • ¥15 解riccati方程组
  • ¥15 display:none;样式在嵌套结构中的已设置了display样式的元素上不起作用?
  • ¥15 使用rabbitMQ 消息队列作为url源进行多线程爬取时,总有几个url没有处理的问题。
  • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决
  • ¥50 树莓派安卓APK系统签名
  • ¥65 汇编语言除法溢出问题