var rabbit = require('./rabbit');
var config = require('./rabbit.json');
var commandLineArgs = require('command-line-args');

var args = commandLineArgs([{ name: 'port', alias: 'p' }]).parse();

var socketConfig = require('./socket');
var socketInst = null;

var queue = require('./queue');

rabbit.connect().then(function(connection) {
	queue(connection).then(function(queue) {
		console.log('- queue is listening for messages -');
		queue.subscribe(function(message, headers) {
			push(headers.channel, message.data.toString());
		});
	});
});

socketInst = socketConfig.connect(args.port);

function push(channel, message) {
	if (socketInst) {
		socketInst.send(channel, message);
	}
}
var rabbit = require('./rabbit');
var commandLineArgs = require('command-line-args');

var args = commandLineArgs([{ name: 'port', alias: 'p' }]).parse();

var socketConfig = require('./socket');
var socketInst = null;

socketInst = socketConfig.connect(args.port);

rabbit.connect().subscribe(function(message) {
	if (socketInst) {
		socketInst.send(message.channel, message.body);
	}
}, function() {
	console.error('- failed to connect to the queue -');
});

Update rabbit consumption code to use the new simplified stream of messages from the queue.
Update rabbit consumption code to use the new simplified stream of messages from the queue.
