Functions
connect([host])
Kind: global function
Param | Type | Description |
---|---|---|
[host] | string |
default is process.env.RMQ_HOST |
Exchange(name, [type], [options])
Kind: global function
Param | Type | Description |
---|---|---|
name | string |
Name of the exchange |
[type] | string |
'direct', 'fanout' etc, default is 'direct' |
[options] | object |
amqp channel.assertExchange options object |
exchange.subscribe(queue, consumeHandler, [routingKey], [prefetch], [messageTtl])
Kind: instance method of Exchange
Param | Type | Description |
---|---|---|
queue | string |
name of queue |
consumeHandler | function |
handler function to call when message arrives on queue |
[routingKey] | string |
optional routing key, defaults to queue name |
[prefetch] | number |
optional number of messages to prefetch, default is 1 |
[messageTtl] | number |
optional time to live for messages on the queue, default is process.env.RMQ_MESSAGE_TTL |
exchange.ack(message)
Kind: instance method of Exchange
Param | Type | Description |
---|---|---|
message | object |
message to ack |
exchange.publish(routingKey, message, [options])
Kind: instance method of Exchange
Param | Type | Description |
---|---|---|
routingKey | string |
optional routing key, defaults to queue name |
message | object |
message to send (JSON object) |
[options] | object |
amqplib options object for publish method |
exchange.sendRPCMessage(queue, message, [timeout])
Kind: instance method of Exchange
Param | Type | Description |
---|---|---|
queue | string |
name of queue |
message | object |
message to send (JSON object) |
[timeout] | number |
time to wait for response in ms, default is process.env.RMQ_RPC_TIMEOUT |
exchange.replyToRPC(message, reply)
Kind: instance method of Exchange
Param | Type | Description |
---|---|---|
message | object |
the original message to reply to |
reply | object |
JSON content of the reply messsage |