amq
A nodejs AMQP implementation built on top of amqplib's channel-oriented api. Connection/Queue/Exchange constructors supporting auto-reconnection and backoff.
Last updated 6 years ago by objectundefined .
BSD · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install amq 
SYNC missed versions from official npm registry.

amq

A nodejs AMQP implementation built on top of amqplib's channel-oriented api. Connection/Queue/Exchange constructors supporting auto-reconnection and backoff.

Examples

###Connection

var amq = require('amq');
var connection = amq.createConnection({ host : 'localhost' , debug : true },{ 
	reconnect : { strategy : 'constant' , initial : 1000 } 
});

Some quick examples

	
	var queue = connection.queue( 'someName' , { durable : true }) ;
	// auto generated queue name, exclusive to conn
	var queue = connection.queue( '' , { exclusive : true }) ;
	var exchange = connection.exchange('myExchange',{durable:true,type:'fanout',confirm:true});
	queue.bind(exchange).then(function(){
		return exchange.publish('foo',{deliveryMode:true,mandatory:true, etc...},function confirmCb(){}).then(function(){
			// written to socket.
		})
	}).then(null,handleErr)
	
	queue.bind('exgName').then(function(){
		...
	}).then(null,handleErr)
	queue.unbind('exgName').then(function(){
		...
	}).then(null,handleErr)
	
	queue.consume(function(message){
		// queue.ack(message);
		// que.nack(message);
		// queue.recover()
	}).then(function(subscription){
		// return connection.sendToQueue(queueName,'foo')
		// return queue.publish(message,opts,cbIfConfirmMode)
	}).then(null,done)

	queue.consume({ prefetch : 1, noLocal : true , etc.. },function(message){
		// queue.ack(message);
		// que.nack(message);
		// queue.recover()
	}).then(function(subscription){
		// return connection.sendToQueue(queueName,'foo')
		// return queue.publish(message,opts,cbIfConfirmMode)
	}).then(null,done)

	// cancel a consumer 	
	queue.consume(fn).then(function(subscription){
		return queue.cancel(subscription.consumerTag)
	}).then(null,done)

	// basick get
	queue.publish('foo').then(function(){
		return queue.get({opts...}).then(function(message){
			// will either get a message or 'false'
		})
	}).then(null,done);
	
	// destroy
	queue.destroy().then(function(){
		queue.check().then(null,assert.ifError).then(null,done.bind(null,null));
	}).then(null,done)
	

Current Tags

  • 0.4.8                                ...           latest (6 years ago)

14 Versions

  • 0.4.8                                ...           6 years ago
  • 0.4.7                                ...           6 years ago
  • 0.4.6                                ...           6 years ago
  • 0.4.5                                ...           7 years ago
  • 0.4.4                                ...           7 years ago
  • 0.4.3                                ...           7 years ago
  • 0.4.2                                ...           7 years ago
  • 0.4.1                                ...           7 years ago
  • 0.4.0                                ...           7 years ago
  • 0.3.9                                ...           7 years ago
  • 0.3.8                                ...           7 years ago
  • 0.3.7                                ...           7 years ago
  • 0.3.6                                ...           7 years ago
  • 0.3.5                                ...           7 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 1
Last Month 4
Dependencies (6)
Dev Dependencies (7)
Dependents (2)

Copyright 2014 - 2016 © taobao.org |