Hermes
Simplified abstraction interface to amqp.node
Publish & subscribe to RabbitMQ queues with simplified publish & subscribe interface methods.
- Connects to RabbitMQ server, establishes a channel, asserts defined queues
- Queues will be created as
durabale
queues, nottransient
.persistent
messages will be saved to disk and survivie broker restarts. Queue Durability
- Queues will be created as
- Automatically buffers publish & subscribe calls until connection is established. (No need to wait for connection to be established before using
publish
orsubscribe
methods from your application.) - Tracks references to subscribe callbacks and provides functionality to stop receiving jobs for one or all task queues. (Very similar to EventEmitter unsubscribe functionality)
- Automatically encodes objects/strings as buffers on publish and decodes to JS Object literals for subscribe callbacks
- Provides subscribe callback with simplified
done
method to send ack message to RabbitMQ and remove tasks from queue
USAGE
/** * Hermes attempts to connect to RabbitMQ upon instantiation, * throws if connection fails. * If using Events, Hermes will throw if binding or asserting failed * during connections */var hermes = ; var { //data automatically decoded into object or string // perform operation w/ data ; // remove job from RabbitMQ queue}; /** * Hermes will auto-queue subscribe & publish calls if * connection to RabbitMQ has not yet been established * * Will throw if first argument is not a string representing * a valid RabbitMQ queue as defined in `queues`, * `publishedEvents`, or `subscribedEvents` options * passed to the constructor * * @param * @param */hermes; /** * Insert job into queue w/ associated job data. * * @param * @param */hermes; /** * Remove bounded functions from queue events (abstracts AMQP cancel & consumerTags) * * @param * @param * @param */hermes;// also, you can optionally remove all workers in a queue by providing null instead of a reference to a single queue consumer callbackhermes; /** * Disconnecting & reconnecting */hermes;hermes; /** * Fetch an array of valid queues * @returns Array<String> */var queues = hermes; /** * Hermes class extends events.EventEmitter and emits the following events: * - 'publish' * - 'subscribe' * - 'unsubscribe' * - 'error' * - 'ready' * Examples: */hermes ; hermes;hermes; hermes;hermes; hermes;hermes;
TESTS
- Tests & coverage are run using Lab
$ npm test
$ npm run test-cov # will auto open Google Chrome
LICENSE
MIT