I have a microservices that process media and at a time I need to provide my microservices to process only one request at atime. So, I need to make a queue using Kue library and one by one pushed new request if it comes. Once 1st request is finished then go to next request but thing is that I have never used queue based processing. please suggest me how to do?
exports['v1'] = (request, response) => {
/** Image processing and send to s3 */
const urls = request.body;
urls.forEach(async url => {
await bufferConvertUtil
.buffer(url)
.then(buffer => {
return processHelperApp.image(buffer, url);
})
.then(data => {
console.log(data);
})
.catch(error => {
console.log('errr ' + error);
fs.appendFile('log.txt', `"${url}",\n`, (err, data) => {
if (err) console.log(err);
});
});
});
responseUtil.success(response, 'done');
};
I need to add new request into queue using kue or rabbitmq library. Once one queue is finished then processing then process next request.