This is a tutorial on the implementation of Pusher Channels in the OutSystems Platform.

Why, you ask? Well, when you are in need of scalable in-app notifications, chat, real-time graphs, geotracking or other reactive solutions in web & mobile applications you need to extend the OutSystems Platform with a messaging API. Pusher.com is one of the major companies that host a publish/subscribe messaging API, also known as pub/sub.

I assume that you have already heard about OutSystems and know how to build an app. If not, you can start reading here, download OutSystems ServiceStudio and follow the tutorials.

When you want to build an integration with Pusher, you have to think about the architecture first. I’ll describe the basic architecture of a pub/sub messaging API.

Pub-Sub Pattern (image credit: MSDN blog)

The Publisher doesn’t know the Subscribers and the Subscribers don’t know the Publisher, which means that they are loosely coupled via an event bus or message broker.

What does this mean in normal English? Here is an example. You (Publisher) want to invite people to a party that you’re hosting. Instead of calling all your friends, you create a message with the topic “Party”. Your friends (Subscribers) that like to party, have a subscription on all posts with the topic “Party”. This way you can reach all your friends that like to party without directly contacting them and without knowing who they are.

Party meme (image credit: Yellow Octopus)

I can already hear you're asking “How do I implement this Pusher component of yours?”. Just read on as I will explain this step by step in the following chapters.

Setting up a Publisher (web)

Create a back-office where you can manage your streams. You need an entity to store your streams (AppId, Channel, Cluster, Event, Key, and Secret). In my case, I also added a static entity for the different Clusters that are available at this moment.