Skip to content

Instantly share code, notes, and snippets.

@liorkesos
Created July 3, 2016 11:46
Show Gist options
  • Save liorkesos/1d186758447e902ef63ead3934f0a263 to your computer and use it in GitHub Desktop.
Save liorkesos/1d186758447e902ef63ead3934f0a263 to your computer and use it in GitHub Desktop.
var Bus = require('busmq');
var bus = Bus.create({redis: ['redis://192.168.0.1:6379', 'redis://[email protected]:6379']);
// or specify the node-redis driver explicitly
// var bus = Bus.create({driver: 'node-redis', redis: ['redis://192.168.0.1:6379', 'redis://[email protected]:6379']);
// or specify the ioredis driver explicitly
// var bus = Bus.create({driver: 'ioredis', redis: ['redis://192.168.0.1:6379', 'redis://[email protected]:6379']);
// or specify the ioredis driver and cluster
// var bus = Bus.create({driver: 'ioredis', layout: 'cluster', redis: ['redis://192.168.0.1:6379', 'redis://[email protected]:6379']);
// or specify the ioredis driver and sentinel
// var bus = Bus.create({driver: 'ioredis', layout: 'sentinel', redis: ['redis://192.168.0.1:26379']);
bus.on('error', function(err) {
// an error has occurred
});
bus.on('online', function() {
// the bus is online - we can use queues, channels ans persistent objects
});
bus.on('offline', function() {
// the bus is offline - redis is down...
});
// connect the redis instances
bus.connect();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment