Setup:
-
Clone repo to a directory and do npm install (required nodejs installed in running system).
-
Create mysql database and and add database details to resources/database.json
-
Run migrations: db-migrate --config resources/database.json -m resources/migrations up
-
start server:
node server.js OR
Daemonize using pm2 module: npm install pm2 -g pm2 start server.js --name="miniq-server" -i 4 //Here 4 instance of app in cluster mode. it shouldnt be more than no of cpu cores for better performance
Now Application will be running on default port 3000.
Api's end points:
All api are of type post
-
http://localhost:3000/enqueue: To enqueue message to queue params: {queue_id: 'q_name', data: ''}
-
http://localhost:3000/dequeue: To dequeue message for a particular queue in fifo params: {queue_id: 'q_id'}
-
http://localhost:3000/ack: To acknowledge consumed queue data. params: {id: 'data_id', ack: 'ACK'} ack value can be ACK/NACK
Dequeue non-acknowledged consumed message by setting up cronjob to run every 1 minute:
cd /path/MiniQ && node tools/reque_nonack.js