Node promise library to handle complex RabbitMQ actions.
Microservices are small programs to handle single task form a complete process chain. The right pattern of communication between microservices is the key to scale your application and solve most of the distributed system problems. RabbitMQ provide a event driven approach to send messages to each other in a Microservice architecture.
https://www.rabbitmq.com/ http://howtocookmicroservices.com/communication/ http://blog.runnable.com/post/150022242931/event-driven-microservices-using-rabbitmq
This library provide a simple wrapper on amqp to interact with Rabbit using following approach:
- Broker
- Publisher
- Subscriber
- Automatically try to reconnect 60 times (configurable) at 1 second apart if broker dies
- Round-robin connection between multiple brokers in a cluster
- Handles messages in memory
- TLS encryption support
- Provide option to
rpc
,send
,listen
,subscribe
andpublish
Create a new amqp connection which will connect to provided url in following structure:
url: 'amqp://' + rabbitmq.username + ':' + rabbitmq.password + '@' + rabbitmq.host + ':' + rabbitmq.port
Options:
url
- URL to the serverDefault: false
prefetch
- Number of channels allowed in a single connectionDefault: 10
heartbeat
- number of sec after which server send back a connection alive heartbeat else throws an errorDefault: 10
reconnectTimeout
- Timeout before trying to reconnect to the serverDefault: 10000
debug
- debug the outputDefault: false
conn
- Connection objectDefault: false
maxRetry
- number times the rabbit connection retry after failure. that calculate to 10 mins of retry before service failsDefault: 60
xMessageTtl
- Time to live for a return queueDefault: 60000
xExpires
- Expiry time for for a queueDefault: 60000
XMaxPriority
- Priority for this queueDefault: 10
noAck
- if true, the broker won't expect an acknowledgement of messages delivered to this consumerDefault: false
ch
- channelDefault: false
caOptions
- socket Options for TLS encryption.default: undefined
cert
- client certkey
- client keypassphrase
- passphrase for keyca
- array of trusted CA certsclientProperties
- user defined properties{ IP: 127.0.0.1 }
Examples: see GITHUB