stitchng / adonis-queue

An addon/plugin package to provide driver-based job queueing services in AdonisJS 4.0+
MIT License
34 stars 9 forks source link

How do I send multiple Jobs in one Queue or run multiple Queues #11

Open yusuf1494 opened 4 years ago

yusuf1494 commented 4 years ago

Hi there, first of all I'm new to node js and adonis so bear with me please. So I was trying to make some heavy process running on queue, including send emails and write some history logs.

Event.on('approve::spending_house', async (parameters)=>{ console.log('HISTORY LOG & EMAIL EVENT FIRED!') await Queue.select('high').andDispatch(new SendEmailApprovePerHouse(parameters.arrayDeptIdEmail, parameters.arrayHouseIdEmail, parameters.year, parameters.logModel, parameters.sendEmailPerBO, parameters.divisi_id)) })

as you can see I created a Job named SendEmailApprovePerHouse it was working fine. But when I add another Job and put it in different event, it shows error Cannot call Queue#process twice.

This is how I defined the new Job in another event:

Event.on('approve::spending_house', async (parameters)=>{ console.log('HISTORY LOG & EMAIL EVENT FIRED!') await Queue.select('high').andDispatch(new SendEmailApprovePerHouse(parameters.arrayDeptIdEmail, parameters.arrayHouseIdEmail, parameters.year, parameters.logModel, parameters.sendEmailPerBO, parameters.divisi_id)) }) Event.on('reject::spending_house', async (parameters)=>{ console.log('HISTORY LOG & EMAIL EVENT FIRED!') await Queue.select('high').andDispatch(new SendEmailRejectPerHouse(parameters.arrayDeptIdEmail, parameters.arrayHouseIdEmail, parameters.year, parameters.logModel, parameters.sendEmailPerBO, parameters.divisi_id)) })`

How can I add another Job or Queue? Thanks.

isocroft commented 4 years ago

Hey @yusuf1494 , thanks for logging this issue :) . I see you are logging a bug. However, you didn't follow our template format for reporting bugs delineated here. Please, help us by repurposing your issue to conform with this template format.

Provide the version of NodeJS you are using. Provide the version of this library which you are using

And all other pertinent info, requested by our issue template

Thank you.

isocroft commented 3 years ago

Hello @yusuf1494 , Happy New Year!! Please provide more information to help us make the library better... Thanks 😃