OpenPaaS Documentation logo OpenPaaS Documentation

Table of contents


The OpenPaaS Core provides several publish/subscribe components:


Both local and global pubsub are providing the same API. Getting a pubsub instance is as easy as getting it from the OpenPaaS dependencies manager:

const {local, global} = dependencies('pubsub');

Once you have the instance, you can subsribe and publish events.


const pubsub = dependencies('pubsub').local;

pubsub.topic('my:topic').subscribe(event => {
  console.log('This will be called when event is published in topic', event);


const pubsub = dependencies('pubsub').local;
const event = {id: 1, data: {}};


Local pubsub

The local pubsub is built using the Node.js EventEmitter. This means that any object can be published in this pubsub component but it is highly encouraged to publish Event instances:

const pubsub = dependencies('pubsub').local;
const { Event } = dependencies('models'); //
const e = new Event(/* Check the doc for args */)


Global pubsub

The global pubsub is built using RabbitMQ as message broker. This allows OpenPaaS to use and rely on all the mechanisms provided by RabbitMQ and so have some high warranty level delivering messages.

Note: It is recommended to push only JSON data in the global pubsub.