Using Pub-Sub messaging pattern to establish richer 2 way experience for mobile users
Before I dive into this blog ; I would like to introduce two critical topics in layman terms.
- Publish <-> Subscribe messaging pattern
In enterprise middleware systems publish<-> subscribe is a well-known messaging pattern to deliver messages based on topic or content based subscription. Applications ( including mobile applications) can be publishers or subscribers . These topics or content based subscriptions are identified by channels and specific attributes ( such as publish or subscription keys) are used to distinguish message delivery.
- WebSocket and/or Socket based communication protocols
In order to establish 2 way flow of information between a publisher and a subscriber in real-time ; a persistent connection is needed either directly between the 2 applications or with a broker/ hub in the middle. Web-socket / Socket based protocols enable this bi-directional persistent connection and API libraries to support this are available in all modern software development stacks.
Ok! Got it!
Having introduced these topics ; let us deep dive on its leverage at SAP Digital Interconnect and why?
First , the “Why?”..
As I highlighted in one of my prior blogs ;
SAP Digital Interconnect provides last mile two-way connectivity to 95% of the global mobile user base using a mobile number as the common communication handle. A vast majority of our newer customers use us for 2-way SMS based engagement, either for customer service or marketing. Hence, 2-way notification flows in synchronous ( for real-time applications such as chat) or asynchronous ( non real-time use cases such as surveys, workflow approvals , quarterly promotion activation etc.) are a critical value driver for our services.
You can read more about our differentiated Push service here ->
Let us elaborate on “Why?” a bit with a specific use case of a retail bank
- Mobile Bank ( an illustrative retail bank) wants to enable quick surveys when its consumers undertake transactions
- To better support its research, it decides to use its mobile app and specifically in-app push notifications
- The survey is initially designed as a simple 1 question Q & A and the user can respond in real-time or at leisure in-app. To illustrate rich engagement , multiple survey templates have been defined
So now , the How..
To showcase this use case ; we leveraged the Publish<-> Subscribe enterprise messaging pattern with Socket/ Web-socket based bi-directional persistent connection as below:
- A common publish channel for all mobile users using the Mobile Bank app to provide a survey response.
- Unique subscribe channel for each registered mobile app user to consume his/ her specific survey notification.
- Persistent connection enabled by Web-socket/socket API’s to deliver surveys for interactive engagement in-app or into a message center
Of course ; we added a registration service to maintain a reference of these channels ( and their keys) with a communication handle that works for SMS – A mobile number!
Schematically , it can be represented as below. Pa is a common publish channel to access inbound responses and C1,C2 are unique device specific channels that deliver surveys to User1 and User2 respectively when Mobile Bank app is engaged.
The survey application sends a survey notification to a transacting and opted in user . The user engages in-app and user responses are collected in the common publish channel from where it is persisted to the survey insights service ( survey application)
To view the implementation in action ; here is a video recording of the interaction sequence.
As you progress through the video , you will find the registered user receives survey questions after completion of a mock fund transfer and while the user is engaged ; the response to the surveys are received back by the online application and displayed as insights.
Having a great partner is critical
Use of Pub-Sub patterns for notification delivery has a drawback ; it is dependent on the ability to maintain persistent connections at high availability. In Pubnub; we found a highly scalable realtime infrastructure-as-a-service with enterprise grade security, 99.999 % SLA backed reliability and global scale.
Reach out to us
The team at SAP Digital Interconnect is here to help you power your interconnect communication use case . Please feel free to reach out to one of us here