-
Notifications
You must be signed in to change notification settings - Fork 1
/
AmqpQueue.coffee
33 lines (26 loc) · 962 Bytes
/
AmqpQueue.coffee
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# AMQP Queue class for AMQP DSL
module.exports = class AmqpQueue
# * `queue( name, options )`
# * `queue( name, callback(queue) )`
# * `queue( name, options, callback(queue) )`
constructor:( @name, options, openCallback) ->
if !@name
throw new Error("Queue must have a name")
@options = {}
@openCallback = ->
if typeof options == "function"
@openCallback = options
else if typeof options == "object"
@options = options
if typeof openCallback == "function"
@openCallback = openCallback
# Real reference to an AMQP::Queue object
@ref = null
# * `.bind( name, routingKey )`
bind:( @exchangeName, @routingKey ) ->
# * `subscribe( callback(message, header, deliveryInfo) )`
# * `subscribe( options, callback(message, header, deliveryInfo) )`
subscribe:( @sOptions, @messageListener ) ->
if typeof @sOptions == 'function'
@messageListener = @sOptions
@sOptions = {}