Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to use limiter and job#jobId together? #908

Closed
michael-land opened this issue Dec 1, 2021 · 4 comments
Closed

How to use limiter and job#jobId together? #908

michael-land opened this issue Dec 1, 2021 · 4 comments

Comments

@michael-land
Copy link

michael-land commented Dec 1, 2021

Seems like bullmq always append limiter#groupKey to the job's id.

Is it possible to define a rate limiter based on group keys and custom job id?

For example

const jobData = [
  {groupKey:"group1", name:"item1"},
  {groupKey:"group2", name:"item2"},
  {groupKey:"group2", name:"item1"}
];


const queue = new Queue('queue1', {
  limiter: { groupKey: 'groupKey' },
})

const worker = new Worker('queue1', {
  concurrency: 20,
  limiter: { duration: 1000, max: 5, groupKey: 'groupKey' },
})

for (const item of jobData) {
  await queue.addJob('jobName', { jobId: item.name })
}

The above code snippet will product jobs with id

name1:group1
name2:group2
name1:group2

expected job id

name1
name2

My goal is each unique job id run only once regardless the group

@manast
Copy link
Contributor

manast commented Dec 2, 2021

That would not be possible with current implementation that requires modifying the jobId in order to pass the group information to the workers. However you may be interested in the Pro version that implements groups in a different way: https://docs.bullmq.io/bullmq-pro/groups

@michael-land
Copy link
Author

pricing for pro?

@manast
Copy link
Contributor

manast commented Dec 2, 2021

Please refer to this page: https://docs.bullmq.io/bullmq-pro/introduction#pricing

@michael-land
Copy link
Author

Thanks, that's too expensive for individual developers like me, I will solve it in application level tho.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants