Build

6 Step Tutorial for Implementing Pub/Sub Messaging

1 min readJoe Hanson on Dec 3, 2014
Try PubNub Today

Free up to 1MM monthly messages. No credit card required.

Subscribe to our newsletter

By submitting this form, you are agreeing to our Terms and Conditions and Privacy Policy.

In 6 steps, we'll show you how to implement pub/sub messaging at its core, and show you how to use PubNub Pub/Sub Messaging to build a real-time app.

Pub/Sub Messaging is at the core of real-time functionality in web, mobile, and Internet of Things applications. To name a few general uses, it enables you to stream data, communicate bi-directionally, broadcast, and signal devices. Really, the use cases are endless.

But in the simplest terms, it revolves around publish and subscribe, where messages are sent from a a publisher to any number of subscribers.

pub sub messaging

And in this tutorial, we’ll do just that. In 6 steps, we’ll show you how to implement pub/sub messaging at its core. In our tutorial we’ll:

  1. Install the PubNub API
  2. Input publish/subscribe keys
  3. Subscribe to a channel
  4. Publish to that channel
  5. Send data on a channel
  6. Stream data on a channel

And that’s it!

In the video below, Stephen and Tomomi we’ll go through the process step-by-step. If you want to follow along, check out our Pub/Sub Quick Start Tutorial for the code from the video, and use your favorite text editor and the JavaScript console.

Building a Real-time App with Pub/Sub Messaging from PubNub on Vimeo.

We have a number of other quick start tutorials around our core features including:

  • Presence: Track the online/offline status of users and devices in your app
  • Storage & Playback: Store real-time message streams for future retrieval and playback
  • Access Manager:Control access permissions to streams of data by person, device, or channel

Check them out and let us know what you think!

More from PubNub

Can Empathy Exist in the Metaverse
News May 16, 20221 min read

Can Empathy Exist in the Metaverse

A roundtable discussion led by PubNub’s COO, Casey Clegg, exploring the topics of what it means to be human in a virtual world.

PubNub Staff

PubNub Staff

How to Advance Telehealth and Virtual Care Technologies
News May 2, 20221 min read

How to Advance Telehealth and Virtual Care Technologies

Dr. Joe Kvedar, Chair of the Board for the American Telemedicine Association, joins our COO, Casey Clegg, to discuss why...

PubNub Staff

PubNub Staff

Another Step Towards Data Security: ISO-27001 Implementation
BuildMay 2, 20221 min read

Another Step Towards Data Security: ISO-27001 Implementation

Today, we are glad to announce that we are currently in the process of implementing ISO-27001 security standards.

PubNub Staff

PubNub Staff