Skip to content
This repository has been archived by the owner on Mar 10, 2020. It is now read-only.

Commit

Permalink
Fixed big message support in Mongo.
Browse files Browse the repository at this point in the history
Closes #97.
  • Loading branch information
mcollina committed Mar 21, 2014
1 parent 442391b commit 91cd7db
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
9 changes: 5 additions & 4 deletions lib/mongo_ascoltatore.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ var MongoAscoltatore = function(opts) {

this.connectionParams = {
capped: true,
size: this._opts.size || 1000,
max: this._opts.max || 100
size: this._opts.size || 10 * 1024 * 1024, // 10 MB
max: this._opts.max || 1000 // documents
};

var that = this;
Expand All @@ -65,14 +65,15 @@ var MongoAscoltatore = function(opts) {
// creating the capped collection where we can exchange messages
that.db.createCollection(that._pubsubCollection, that.connectionParams, function(err, collection) {
if (err) {
throw new Error(err);
that.emit('error', err);
} else  {
that.collection = collection;

// be sure to have a capped collection on the run
that.db.executeDbCommand({
"convertToCapped": that._pubsubCollection,
size: that.connectionParams.size
size: that.connectionParams.size,
max: that.connectionParams.max
}, function ready() {
debug('ready');

Expand Down
13 changes: 13 additions & 0 deletions test/mongo_ascoltatore_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,17 @@ describe("ascoltatori.MongoAscoltatore", function() {
}
});
});

it("should publish a big payload", function(done) {
var that = this;
var payload = new Buffer(5 * 1024);
that.instance.sub("hello/*", function(topic, value) {
expect(value).to.eql(payload);
done();
}, function(err) {
that.instance.pub("hello/123", payload, function(err) {
console.log(err);
});
});
});
});

0 comments on commit 91cd7db

Please sign in to comment.