Reputation: 13
I have dilemma with implementation for Laravel Jobs - queues. I need make queue for shops entities - orders and products synchronization to other api (limited requests for minute). But I need that shops don't influence each other.
E.g. I have shop that need synchronize 1000 products. 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. I try set delay([6s])
for Laravel Job, but same result too.
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.
Any idea how implement this situation. Thank you.
Upvotes: 0
Views: 1162
Reputation: 94
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);
Upvotes: 0