问题
- I have multi tenant application.
- Each tenant has multiple actions (sync_customers, sync_metafileds, install_code, verify_code etc etc) for which i need to do a API calls.
- API call has limit of 2 calls per second (max 41 calls in one minute).
case 1.
- i. suppose one tenant has 10,000 customers. And syncing process is running.
- At the same time tenant add request for install_code. (install_code needs min 16 API calls.)
- Now either i can stop sync_customers and start install_code based on priority or just add all calls to queue.
What i need is
- different queue for different tenant.
- queue needs to be priority.
- if higher priority task comes in between any queue process.finish it first and continue on pending tasks.
- If No other pending tasks then just optimised server resources and close that queue.
i am using AWS and laravel v5.x with php version 7.x
Hope every one got my point.
Thanks in advance.
回答1:
I created one custom command queue:work_stores with argument {user_id}.
Which run queue:work with arguments --once=true
$this->call('queue:work', [
"--once" => true,
"database"
]);
One flag which track if the current queue:work_stores is running or not.
Check full code https://gist.github.com/little-isaac/a6d70c82f372406f827fb3b399745c8e
来源:https://stackoverflow.com/questions/48150997/laravel-how-can-we-manage-different-queue-for-each-tenant-in-multi-tenant-applic