0.0.7 • Published 5 years ago

rmq-wrapper v0.0.7

Weekly downloads
1
License
MIT
Repository
github
Last release
5 years ago

Functions

connect(host)

Kind: global function

ParamTypeDescription
hoststringdefault is process.env.RMQ_HOST'amqp://rabbitmq:5672'

Exchange(name, type, options)

Kind: global function

ParamTypeDescription
namestringName of the exchange
typestring'direct', 'fanout' etc, default is 'direct'
optionsobjectamqp channel.assertExchange options object

exchange.subscribe(queue, consumeHandler, routingKey, prefetch, messageTtl)

Kind: instance method of Exchange

ParamTypeDescription
queuestringname of queue
consumeHandlerfunctionhandler function to call when message arrives on queue
routingKeystringoptional routing key, defaults to queue name
prefetchnumberoptional number of messages to prefetch, default is 1
messageTtlnumberoptional time to live for messages on the queue, default is process.env.RMQ_MESSAGE_TTL10000

exchange.ack(message)

Kind: instance method of Exchange

ParamTypeDescription
messageobjectmessage to ack

exchange.publish(routingKey, message, options)

Kind: instance method of Exchange

ParamTypeDescription
routingKeystringoptional routing key, defaults to queue name
messageobjectmessage to send (JSON object)
optionsobjectamqplib options object for publish method

exchange.sendRPCMessage(queue, message, timeout)

Kind: instance method of Exchange

ParamTypeDescription
queuestringname of queue
messageobjectmessage to send (JSON object)
timeoutnumbertime to wait for response in ms, default is process.env.RMQ_RPC_TIMEOUT10000

exchange.replyToRPC(message, reply)

Kind: instance method of Exchange

ParamTypeDescription
messageobjectthe original message to reply to
replyobjectJSON content of the reply messsage