1.0.44 • Published 4 years ago
@alicilin/node-mmq v1.0.44
Message Queue System on Mongodb & Redis
'use strict';
const Daemon = require('./Daemon');
const MMQ = require('./MMQ');
const Worker = require('./Worker');
let moptions = [
'mongodb://localhost:27017',
{
auth: {
username: 'root',
password: 'test123'
},
useNewUrlParser: true,
useUnifiedTopology: true
}
];
let roptions = [
{
host: 'localhost',
port: 6379,
key: 'mrqueue'
}
];
const server = new Daemon({ mongo: moptions, redis: roptions, port: 8080, secret: 'mmq-123', });
const mmq1 = new MMQ({ servicename: 'master', channel: 'test', ip: 'localhost', port: 8080, secret: 'mmq-123' });
const mmq2 = new MMQ({ servicename: 'child', channel: 'test', ip: 'localhost', port: 8080, secret: 'mmq-123' });
async function main() {
await server.start();
for (let i = 1; i < 10; i++) {
await mmq1.send({ service: '*', event: 'worked', retry: 15, data: { message: 'okeyyyy - ' +i } });
}
setTimeout(() => (mmq1.send({ service: '^chil', event: 'worked', retry: 15, data: { message: 'okeyyyy lets go' } })), 3 * 1000);
let worker = new Worker({ MMQI: mmq2 });
worker.on('worked', async (data, unlock) => {
// (await (new Promise(r => setTimeout(r, 1000))));
console.log(data.data.message, 'worker 1');
await new Promise(r => setTimeout(unlock, 1000));
});
worker.start();
}
main()
1.0.39
4 years ago
1.0.38
4 years ago
1.0.40
4 years ago
1.0.44
4 years ago
1.0.43
4 years ago
1.0.42
4 years ago
1.0.41
4 years ago
1.0.33
4 years ago
1.0.32
4 years ago
1.0.37
4 years ago
1.0.36
4 years ago
1.0.34
4 years ago
1.0.31
4 years ago
1.0.29
4 years ago
1.0.30
4 years ago
1.0.28
4 years ago
1.0.22
4 years ago
1.0.21
4 years ago
1.0.20
4 years ago
1.0.26
4 years ago
1.0.25
4 years ago
1.0.24
4 years ago
1.0.23
4 years ago
1.0.27
4 years ago
1.0.19
4 years ago
1.0.18
4 years ago
1.0.17
4 years ago
1.0.16
4 years ago
1.0.15
4 years ago
1.0.14
4 years ago
1.0.13
4 years ago
1.0.12
4 years ago
1.0.10
5 years ago
1.0.9
5 years ago
1.0.8
5 years ago
1.0.7
5 years ago
1.0.6
5 years ago
1.0.5
5 years ago
1.0.4
5 years ago
1.0.3
5 years ago
1.0.2
5 years ago
1.0.1
5 years ago
1.0.0
5 years ago