amqplib-easy
Advanced tools
Comparing version 3.1.0 to 3.2.0
@@ -54,2 +54,3 @@ - [`Create(amqpUrl)`](#createamqpurl---amqp) | ||
Defaults to an empty object | ||
- `parse`: (function) parse string content of message. Defaults to `JSON.parse` | ||
- `prefetch`: (number) of messages to fetch when consuming. Defaults to `1` | ||
@@ -56,0 +57,0 @@ - `queue`: (string) name of the queue to use |
@@ -43,2 +43,3 @@ 'use strict'; | ||
exchangeOptions: {durable: true}, | ||
parse: JSON.parse, | ||
queueOptions: {durable: true}, | ||
@@ -85,6 +86,6 @@ prefetch: 1 | ||
try { | ||
msg.json = JSON.parse(msg.content.toString()); | ||
msg.json = options.parse(msg.content.toString()); | ||
return handler(msg, ch); | ||
} catch (err) { | ||
console.error('Error converting AMQP message content to JSON.', err); | ||
console.error('Error deserializing AMQP message content.', err); | ||
} | ||
@@ -91,0 +92,0 @@ }; |
{ | ||
"name": "amqplib-easy", | ||
"version": "3.1.0", | ||
"version": "3.2.0", | ||
"description": "Simplified API for interacting with AMQP", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
amqplib-easy | ||
============ | ||
[![Build Status](https://travis-ci.org/lanetix/node-lanetix-amqp-easy.svg?branch=api-doc)](https://travis-ci.org/lanetix/node-lanetix-amqp-easy) | ||
[![Build Status](https://travis-ci.org/lanetix/node-lanetix-amqp-easy.svg?branch=master)](https://travis-ci.org/lanetix/node-lanetix-amqp-easy) | ||
@@ -5,0 +5,0 @@ [amqplib](https://github.com/squaremo/amqp.node) but easy! Let us manage your |
@@ -43,2 +43,27 @@ /*globals it:false*/ | ||
it('should accept alternate parser', function (done) { | ||
amqp.consume( | ||
{ | ||
exchange: 'cat', | ||
parse: function () { return { name: 'Fred' }; }, | ||
queue: 'found_cats', | ||
topics: [ 'found.*' ] | ||
}, | ||
function (cat) { | ||
var name = cat.json.name; | ||
try { | ||
name.should.equal('Fred'); | ||
done(); | ||
} catch (err) { done(err); } | ||
} | ||
) | ||
.then(function (c) { | ||
cancel = c; | ||
return BPromise.all([ | ||
amqp.sendToQueue({ queue: 'found_cats' }, new Buffer('dsadasd')) | ||
]); | ||
}) | ||
.catch(done); | ||
}); | ||
it('should handle buffers reasonably', function (done) { | ||
@@ -45,0 +70,0 @@ var catCount = 0; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
21449
15
358