【发布时间】:2020-03-05 10:07:42
【问题描述】:
我创建了一个在特定日期和时间(例如明天)执行的 Laravel 作业。我想添加一个手动按钮,它会覆盖时间并在其设置的执行时间之前执行该排队的作业。 单击该按钮会创建一个 ajax 调用并将一个作业 ID 发送到服务器。这将导致今天而不是明天执行的作业。
我们可以使用以下命令手动重试失败的作业:
php artisan queue:retry JOBIDHERE
我不确定使用什么来执行排队的作业。
我可以得到job ID,但不知道Laravel Job是否可以在设定的执行时间之前执行。
我在谷歌上搜索,但没有找到有此类问题和解决方案的人。
我正在使用 Laravel 5.8 版。 使用 MySQL 5.7
更新:
以下是排队作业的负载。
我尝试使用 Json Decode 并对其进行解码,但我不确定是否可以更新该队列的命令,以便我可以更新队列的日期和时间并将其保存回排队的作业记录。
{"displayName":"App\\Jobs\\Payway\\UpdateCustomerInvestment","job":"Illuminate\\Queue\\CallQueuedHandler@call","maxTries":null,"delay":null,"timeout":null,"timeoutAt":null,"data":{"commandName":"App\\Jobs\\Payway\\UpdateCustomerInvestment","command":"O:40:\"App\\Jobs\\Payway\\UpdateCustomerInvestment\":17:{s:57:\"\u0000App\\Jobs\\Payway\\UpdateCustomerInvestment\u0000transactionType\";s:7:\"payment\";s:57:\"\u0000App\\Jobs\\Payway\\UpdateCustomerInvestment\u0000principalAmount\";d:9999;s:56:\"\u0000App\\Jobs\\Payway\\UpdateCustomerInvestment\u0000customerNumber\";s:4:\"BR-2\";s:50:\"\u0000App\\Jobs\\Payway\\UpdateCustomerInvestment\u0000currency\";s:3:\"aud\";s:58:\"\u0000App\\Jobs\\Payway\\UpdateCustomerInvestment\u0000singleUseTokenID\";N;s:55:\"\u0000App\\Jobs\\Payway\\UpdateCustomerInvestment\u0000payway_helper\";O:29:\"App\\Http\\Helpers\\PaywayHelper\":0:{}s:54:\"\u0000App\\Jobs\\Payway\\UpdateCustomerInvestment\u0000impodenceKey\";s:36:\"afedfc34-d08e-4831-a4aa-29de930d6b98\";s:49:\"\u0000App\\Jobs\\Payway\\UpdateCustomerInvestment\u0000headers\";a:0:{}s:60:\"\u0000App\\Jobs\\Payway\\UpdateCustomerInvestment\u0000localInvestmentObj\";O:45:\"Illuminate\\Contracts\\Database\\ModelIdentifier\":4:{s:5:\"class\";s:33:\"App\\Models\\Investment\\Investments\";s:2:\"id\";i:374;s:9:\"relations\";a:2:{i:0;s:8:\"investor\";i:1;s:13:\"investor.user\";}s:10:\"connection\";s:5:\"mysql\";}s:54:\"\u0000App\\Jobs\\Payway\\UpdateCustomerInvestment\u0000paywayTotals\";O:45:\"Illuminate\\Contracts\\Database\\ModelIdentifier\":4:{s:5:\"class\";s:38:\"App\\Models\\Banking\\Payway\\PaywayTotals\";s:2:\"id\";i:1;s:9:\"relations\";a:0:{}s:10:\"connection\";s:5:\"mysql\";}s:6:\"\u0000*\u0000job\";N;s:10:\"connection\";N;s:5:\"queue\";s:6:\"payway\";s:15:\"chainConnection\";N;s:10:\"chainQueue\";N;s:5:\"delay\";O:13:\"Carbon\\Carbon\":3:{s:4:\"date\";s:26:\"2019-11-12 23:35:22.752222\";s:13:\"timezone_type\";i:3;s:8:\"timezone\";s:16:\"Australia\/Sydney\";}s:7:\"chained\";a:0:{}}"}}
更新 2:
当我反序列化payload命令时,得到如下信息。
所以我正在尝试更新该延迟日期,希望它会起作用。
但从“朱利安·斯塔克”的回答来看,我可能还需要更新 available_at。
我的理论是当队列运行时,它会根据available_at 寻找工作。但是,当作业正在执行并且它有延迟时,它可能不会在那个特定时间执行。这个理论还有待检验。
我将更新这两个日期时间并检查一切是否顺利。
【问题讨论】: