rabbitmq-tt
Rabbitmq lib
Last updated 2 years ago by thanhtuan .
ISC · Original npm · Tarball · package.json
$ cnpm install rabbitmq-tt 
SYNC missed versions from official npm registry.

Cài module:

$ npm install --save rabbitmq-tt

Sử dụng module

import {Rpc, Publisher, WorkerManager, ExchangeManager} from 'rabbitmq-tt';

Rpc

import {Rpc} from 'rabbitmq-tt';
var rpc = Rpc('amqp://username:password@host/vhost', {timeout: 10000});

// Rpc client
var client = rpc.client();

setInterval(function() {
	let request = client.request('hello', {test: 1});

	request.then(data => {
		console.log(data);
	}).catch(e =>{
		console.log(e);
	});
}, 1000);

// Rpc server
var server = rpc.server();

server.on('hello', function(data, callback) {
	console.log('server todo', data);
	callback(null, {a: 'Hi'});
});

Publish to worker

import {Publisher} from 'rabbitmq-tt';

var publisher = Publisher('amqp://username:password@host/vhost');

var nb = 0;
setInterval(function() {
	publisher.publish('', 'queuename', {number: nb++});
}, 100);

Worker

import {WorkerManager} from 'rabbitmq-tt';
var workerManager = WorkerManager('amqp://username:password@host/vhost');

const handle = (params, callback) => {
	console.log(params);
	setTimeout(function() {
		callback();
	}, 0);
};

workerManager.addWorker('queuename', handle);

Current Tags

  • 0.0.1                                ...           latest (2 years ago)

1 Versions

  • 0.0.1                                ...           2 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 1
Last Day 0
Last Week 1
Last Month 1
Dependencies (4)
Dev Dependencies (4)
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |