msfidelis / rsmq-promise

Promise interface for RSMQ
https://github.com/smrchy/rsmq
MIT License
28 stars 7 forks source link

A long running example would be nice #8

Closed midnightcodr closed 5 years ago

midnightcodr commented 5 years ago

Hi, is there an example showing a long running process as a listener? That is, don't quit rsmq after processing message(s).

So basically I wanted to run the following over and over without relying on crontab.

rsmq.receiveMessage({qname: 'myqueue'})
    .then(message => doSomethingAbout(message))
    .catch(err => console.log(err))
msfidelis commented 5 years ago

You can create worker based on setInterval


const RSMQPromise = require('rsmq-promise');

const rsmq = new RSMQPromise({
    host: "127.0.0.1", 
    port: 6379
});

setInterval(() => {
    rsmq.receiveMessage({qname: 'myqueue'})
        .then(message => doSomethingAbout(message))
        .catch(err => console.log(err))
}, 1000);
midnightcodr commented 5 years ago

I am leaning towards a more complete solution https://github.com/mpneuried/rsmq-worker after doing some research. Thanks for the response @msfidelis.