amqp-dsl

Amqp-DSL - Fluent interface for node-amqp

Fluent Interface for dealing with AMQP on NodeJS

AMQP-DSL is a fluent interface wrapper for node-amqp and help you write AMQP binding code in a clean and efficient way.

$ npm install amqp-dsl
 
amqp = require 'amqp-dsl'
 
amqp.login(
 
  login: 'user'
  password: 'password'
  host: 'localhost'
 
).connect((err, amqp) ->
 
  if err
    throw err
    return
 
  console.log 'We are connected !'
 
)
 
AmqpDsl = require 'amqp-dsl'
 
AmqpDsl.login(
  login: 'legen'
  password: 'dary'
)
.on( 'close'() -> console.error "RabbitMQ connection closed" )
.on( 'error'(err) -> console.error "RabbitMQ error"err )
.on( 'ready'() -> console.log "Connected to RabbitMQ" )
 
.queue( 'testQueue'(queue) -> console.log "Connected to Queue"queue.name )
  .bind( 'stream''#' )
  .bind( 'stream2''routing.key' )
  .subscribe( (message, header, deliveryInfo) -> )
 
.queue( 'queue2' )
  .bind( 'search''#.ok' )
 
.queue( 'queue3'passive:true )
 
.connect( (err, amqp) ->
 
  if err
    throw err
    return
 
  # Do other stuff with `amqp` like subscribing to a queue 
 
  queue3 = amqp.queues.queue3
 
  queue3.subscribe( ack:true( message, header, deliveryInfo ) ->
    console.log "Hey ! We got one new message !"
    queue3.shift()
  )
 
)

See examples/ and docs/ for more information.

  • login( options = {} )
  • on( event, listener )
  • .exchange( name, options )
  • .exchange( name, callback(exchange) )
  • .exchange( name, options, callback(exchange) )
  • .queue( name, options )
  • .queue( name, callback(queue) )
  • .queue( name, options, callback(queue) )
  • .subscribe( callback(message, header, deliveryInfo) )
  • .subscribe( options, callback(message, header, deliveryInfo) )
  • .bind( name, routingKey )
  • .connect()
  • .connect( callback(err, amqp) )
  • .connect( amqp, callback(err, amqp) )

The amqp argument is simply hashtable with the following properties:

  • queues (hashtable of AMQP::queues)
  • exchanges (hashtable of AMQP::Exchange)
  • connection (AMQP::Connection)
$ cake doc

... and browse docs/

$ npm test

v2.0.0 - Updated node-amqp to 0.2.0 and async to 0.9.0 v1.0.3 - Support for .connect() v1.0.2 - Critical bug fix v1.0.1 - .bind & .subscribe can now be called multiple times. This is the behavior that should have been in place since the beginning.

Donate Bitcoins

Copyright (c) 2014 Francois-Guillaume Ribreau Licensed under the MIT license.