Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
AMQP-DSL is a fluent interface for AMQP (RabbitMQ,...) on NodeJS
CoffeeScript CSS JavaScript
Tree: f4d8e49bde

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
docs
examples
lib
src
test
.gitignore
.travis.yml
Cakefile
LICENSE
README.md
package.json

README.md

Fluent Interface for dealing with AMQP on NodeJS Build Status

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

Installation

$ npm install amqp-dsl

Usage overview

Simple connection (more details: docs/example-connection)

    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 !'

    )

Simple example (more details: docs/example-simple)

    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', '#' )
      .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.

API

.login

  • login( options = {} )

.on

  • on( event, listener )

.exchange

  • .exchange( name, options )
  • .exchange( name, callback(exchange) )
  • .exchange( name, options, callback(exchange) )

.queue

  • .queue( name, options )
  • .queue( name, callback(queue) )
  • .queue( name, options, callback(queue) )

.queue(...).subscribe

  • .subscribe( callback(message, header, deliveryInfo) )
  • .subscribe( options, callback(message, header, deliveryInfo) )

.queue(...).bind

  • .bind( name, routingKey )

.connect

  • .connect( amqp, callback(err, amqp) )
  • .connect( callback(err, amqp) )

    amqp contains * queues (hashtable of AMQP::queues) * exchanges (hashtable of AMQP::Exchange) * connection (AMQP::Connection)

Documentation

Build documentation

$ cake doc

... and browse docs/

Test

$ npm test
Something went wrong with that request. Please try again.