In this Quick Start, we will lead you through a step-by-step guide of how to create and deploy a block in the PubNub Data Stream Network.
Just like other features of the Data Stream Network,
PubNub BLOCKS must be enabled on a per Keyset basis.
To enable a Keyset:
- Go to the Keyset Configuration via the admin portal.
- Scroll down to the PubNub feature section and turn on the
Voila! You can now create
BLOCKS for this Keyset.
Now that your Keyset is enabled for
PubNub BLOCKS, let's create a block.
- Go to the
BLOCKSpage by clicking the
BLOCKSicon in side bar.
- Create a block by entering a name and a description in the square tile.
The block's name and description can always be changed.
The block name must be unique for all
A block is used as a container to group related
EH(s) together. Since we just created this block, it contains no Event Handlers (
EH), so we'll create it now.
To create an Event Handler(
EH), click on the New Event Handler icon.
In the pop up window, configure your
- Entering a name.
- Entering an Event Handler Type.
- Entering one or more channels.
EH must have an Event Handler Type (
ET) defined for it.
Currently three types of Event Handlers are supported:
- Before Publish or Fire
- After Publish or Fire
- After Presence
For more information on Event Handler Types, please see Event Handler Types
EH can be triggered by messages sent to one or several channels, and must always have at least one channel defined for it.
EH to execute against messages sent to a single channel, enter the channel name in the channel field.
if you adopt a naming convention with 2 levels of depth when specifying your channels, you can subscribe to channels by using
For example, if you have several channels named
foo.barN, your Event Handler can subscribe to all these channels by entering in the channel field:
For more information on wildcard subscribing see http://www.pubnub.com/knowledge-base/categories/wildcard-subscribe
Now that you have coded all the
EH(s) in your block, you have to provision the servers, scale out the network, and deploy your block.
This is all done simply by clicking the Run button.