Pub/Sub Messaging

At A Glance

Backendless features a powerful publish/subscribe (pub/sub) messaging system with easy-to-use APIs. A pub/sub implementation is a means of exchanging messages that consists of three components: publishers, subscribers, and a message broker (which in our case is Backendless). Your app can subscribe to receive messages using the Subscription API, and thus becomes a “Subscriber”. Publishers send messages to the message queue using the Publishing API, and the backend delivers messages to subscribers. Message delivery can be unconditional, where all messages are delivered to subscribers, or conditional, where realtime messages are only delivered if they match the subscription criteria. Backendless supports broadcasts, which deliver messages to multiple recipients, and point-to-point messaging, where a message is delivered to a single recipient.

Publish-Subscribe Messaging

Cross-Platform Message Delivery

Most message broker frameworks support only a few languages, while Backendless automatically transforms and adapts all messages to the native format on the subscriber side. Messages published can contain any data, including primitive values (strings, numbers, dates, booleans), custom classes, or collections of objects. For example, your Android version of the app sends an Order that contains an array of Java objects. An iOS subscriber will automatically receive that message as a Swift (or Objective-C) array of the corresponding native Order objects. Transformations are handled for all supported client types, which makes Backendless Messaging a complete cross-platform solution.

Powerful Data Broadcast

Backendless uses the publish/subscribe (pub/sub) paradigm to process messages and broadcast message data. That means that as soon as a message is published into a channel, it is instantaneously delivered to all subscribers of that channel. Message delivery is handled in real-time via a highly-optimized system for routing messages to minimize publish-to-delivery time, removing any need for data polling by subscribers. Backendless’ messaging infrastructure can handle millions of subscribers and messages queues for an app, and all of our SDKs support both Publishing APIs and Subscription APIs so you don’t have to build your own message broker.

Conditional Subscriptions

Your app can use the Subscription API to receive messages that match the specified criteria, thus making it a condition-based subscription. Published messages can include message headers to enable “interest-based” subscriptions. Backendless delivers these messages only to the subscribers that match the delivery criteria. The subscription APIs use the same familiar SQL syntax to describe the condition(s) a message must match for it to be delivered to the subscriber.

Customizable with Cloud Code

Cloud Code supports pub/sub messaging event handlers which can be used to apply some additional processing to published messages. For example, a Cloud Code event handler for the Publishing API can store published messages in the database. The Publishing API can also be used in Cloud Code to send out messages to subscribers. You can use Cloud Code timers to send out messages on a predefined schedule, allowing you to automate your app’s messaging.

Great for Games

Publish/Subscribe is a great fit for multiplayer games. The API can be used to manage and exchange player information, synchronize game status, and facilitate player-to-player chat. Real-time message delivery guarantees that players always receive the latest data instantly. Condition-based message delivery and interest-based subscriptions minimize traffic and optimize targeted delivery, ensuring players see only the messages that are relevant to them. Pub-sub messaging is a great way to handle add chat message capability to any app.

Online Message Publishing

Backendless Console includes a simple-yet-powerful graphical user interface for publishing messages. You can enter your message content and add message headers for conditional delivery, meaning not all subscribers will receive the same message. As messages get published, you are able to see the real-time stream of messages for any of your pub/sub messaging channels as well as inspect their content.

Instant Mobile Chat

Backendless Code Generator can instantly create a fully functional chat app for you to experience. This app demonstrates the power of our publish/subscribe messaging APIs. Without writing a single line of code, you can experience the API and see message handling in action live on your mobile devices. The code generator is available for Android, iOS, and JavaScript chat implementations.