[英]Laravel Jobs - dynamic queues, delay between jobs
I have dilemma with implementation for Laravel Jobs - queues.我对 Laravel Jobs - queues 的实现进退两难。 I need make queue for shops entities - orders and products synchronization to other api (limited requests for minute).
我需要为商店实体排队 -订单和产品与其他 api 同步(分钟请求有限)。 But I need that shops don't influence each other.
但我需要商店不要相互影响。
Eg I have shop that need synchronize 1000 products.例如,我有需要同步 1000 种产品的商店。 But in same time there is other shop with product that needed to be synchronized too.
但同时还有其他商店的产品也需要同步。
What I try:我尝试什么:
for delay: sleep([6s])
in Laravel Job handle (not working) because when I get 3 products jobs at same time, I cannot send him with this delay between each other.对于延迟: Laravel 中的
sleep([6s])
作业句柄(不工作)因为当我同时获得 3 个产品作业时,我无法在彼此之间以这种延迟发送他。 I try set delay([6s])
for Laravel Job, but same result too.我尝试为 Laravel 作业设置
delay([6s])
,但结果也相同。
for avoid waiting: I tought about dynamic creation queues (for each shop separated) but I don't know if Laravel Jobs makes smoething like this possible.为了避免等待:我对动态创建队列(每个商店分开)进行了讨论,但我不知道 Laravel Jobs 是否使这样的 smoeth 成为可能。
Any idea how implement this situation.知道如何实现这种情况。 Thank you.
谢谢你。
Try using carbon, Eg:尝试使用碳,例如:
$dateTime = "2022-08-12 12:00:00";
$carbonDate = Carbon::parse($date);
JobsPublishArticle::dispatch()->delay($dateTime);
Or或者
$dateTime = Carbon::now()->addSeconds(10); // you can use minutes, hours, etc too.
JobsPublishArticle::dispatch()->delay($dateTime);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.