Laravel how can we manage different queue for each tenant in multi tenant application?

£可爱£侵袭症+ 提交于 2019-12-11 06:58:49

问题


  1. I have multi tenant application.
  2. Each tenant has multiple actions (sync_customers, sync_metafileds, install_code, verify_code etc etc) for which i need to do a API calls.
  3. 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

  1. different queue for different tenant.
  2. queue needs to be priority.
  3. if higher priority task comes in between any queue process.finish it first and continue on pending tasks.
  4. 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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!