
Company News
Socket Named Top Sales Organization by RepVue
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.
mongo-brocast
Advanced tools
Pub/Sub with MongoDB. A Brocast implementation.
Reactive, and easily extensible.
This implementation is EventStore compatible, as you can subscribe to past events.
var Brocast = require('mongo-brocast').Brocast;
Args:
db - Instance of Db() from MongoDB's native driver.opts - Object with Options.Options:
channelSize - (default=16MB) Max amount of bytes for each channel.
If a channel will exceed this size, new events will overwrite old ones.maxEventsPerChannel - (default=1000) If your channel is less than channelSize, what's the max amount of events
to store.ns - (default='pubsub'). The prefix for the collection names that would be created by this module.separator - (default=':'). The separator between ns and the pubsub related namespaces.collectionNameGenerator - (Optional function). You can implement your own naming scheme.dao - (Optional object). You can implement your own MongoDB Data Access Object.
The default naming scheme is: '%ns%%separator%%CHANNEL_NAME%.writeStreamFactory - (Optional function). Returns a Writeable Stream that stores events in MongoDB.
You can implement your own storage scheme.readStreamFactory - (Optional function). Returns a readable stream with events being published. You can implement
your own retrieval strategy.Events:
error - All errors would be redirected to the main instance of MubSub.Returns a Channel instance from brocast.
Args:
channelName - The name of the channel.Events:
newSubscriber - When someone subscribes to this channel it emits the Subscriber object.Publishes a new message to the channel.
Args:
name - The name of the event to publish.message - The message to publish. It can be String, Array or Json object.Returns an instance of brocast subscriber object, which is a Readable stream.
Args:
eventName - The name of the event to subscribe to.opts - Object with options.Options:
start - The last eventId that you dispatched. If undefined, it'll subscribe only to new events. If the
value is 0 it will subscribe to all events available in the channel.Events:
unsubscribe - This event is emitted if you call the unsubscribe method.data - The events that are being dispatched.A dispatched event looks like this:
{
_id: 542bf84fa51ffd383cea96ff,
name: 'test event',
channel: 'tstChannel',
timestamp: 1412167759481,
msg: 386.00159669294953
}
Unsubscribe from receiving events.
var MongoClient = require("mongodb").MongoClient,
MubSub = require('../lib/mubsub');
var dbConfig = {
"uri": "mongodb://192.168.111.222:27017/mubsub",
"options": {
"server": {
"socketOptions": {
"keepAlive": 1
}
}
}
}
MongoClient.connect(dbConfig.uri, dbConfig.options, function (err, db) {
var client = new MubSub(db);
var channel = client.channel('tstChannel');
var sub = channel.subscribe('test event').on('data', function (event) {console.log('received', event)})
channel.publish('test event', Math.random()*1000);
});
Event Struct and decouple it from Mongo. i.e. id instead of _id.lastId to act as an alias for startWith npm do:
npm install brocast
MIT
FAQs
Pub/Sub with MongoDB. A `Brocast` implementation.
We found that mongo-brocast demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Company News
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.

Security News
NIST will stop enriching most CVEs under a new risk-based model, narrowing the NVD's scope as vulnerability submissions continue to surge.

Company News
/Security News
Socket is an initial recipient of OpenAI's Cybersecurity Grant Program, which commits $10M in API credits to defenders securing open source software.