This blog series takes you through a hypothetical scenario and shows you how simple it is to extend the existing functionality in the legacy system - be it S4HANA, or a simple java/JSP application - using the serverless offerings from SAP Cloud Platform (along with SAP Cloud Platform Open Connectors). The entire end - to - end scenario covers the following services.
- SAP Cloud Platform Enterprise Messaging - Messaging as a service
- SAP Cloud Platform Functions (Beta) - Functions as a service
- SAP Cloud Platform Open connectors
- SAP Cloud Platform Backend service(Beta) - Backend as a service
Note: Functions-as-a-Service (Beta) and the Backend-as-a-Service (Beta) will be phased out but great for PoCs. ‘SAP Cloud Platform Extension Factory, serverless runtime’ is offering the same functionalities as well (Functions), plus OData Provisioning (and maybe in future also Backend-as-a-Service. For productive use, please refer
https://help.sap.com/viewer/product/XF_SERVERLESS_RUNTIME/Cloud/en-US
Scenario
The architecture diagram below depicts the scenario which will be discussed in the blog series.
![](/legacyfs/online/storage/blog_attachments/2020/04/architecture-3.png)
The legacy application based on J2EE creates promotions for the products sold by a hypothetical company. It has been in use for many years and now the company wants to alert the customers regarding the upcoming promotions, in addition to publishing it on their website. There is also an idea for extending this to include promotion/campaign tracking in the future.
A simple server-less solution for this scenario could look like this:
- When the promotion is created in the legacy application, it is sent to a queue/topic in the enterprise messaging service.
- The Enterprise Messaging service stores the message in the queue/topic.
- One or multiple functions can be triggered by the queue/topic and alert their customers through open connectors.
- The Backend service stores the contact details for the customers and can be utilised to store any information in the future such as tracking data which can be analysed.
Following are the pre-requisites. All of them are available in the trial version of SAP Cloud Platform Foundry.
- A trial account in SAP Cloud Platform (Foundry).
- ‘Open Connectors’ service enabled in your trial account.
- An instance of SAP Enterprise Messaging service
- An instance of SAP Cloud Platform Functions.
- Subscription of SAP Cloud Platform Backend service
- An instance of 'Authorization & Trust Management' service
Legacy Application
A Java-based application is used to create promotions in the legacy system. The user enters a promotion name, ID, applicable product range, the customer groups the promotion is valid for and the validity dates. This application just saves the promotion in the system. Website and Twitter account of the company are updated manually after the promotions are created in the system.
The extension which we develop using the server-less offerings in the SAP Cloud Platform will provide the following additional functionalities:
- Once the promotion is created, the extension sends a Whatsapp message to all the registered customers of the chosen customer group.
- If the promotion is valid for all the customer groups, it also updates the twitter account with the details of the upcoming promotion.
This requires only a few lines of code in the legacy application. Let us look at the steps we need to perform to set this scenario up in the cloud foundry account.
Let us start with the easiest service - SAP Cloud Platform Enterprise Messaging.
This serverless cloud messaging service connects applications, services, and systems so they can interact with each other through messages and events.
Navigate to your global SAP Cloud Platform account and under “Entitlements” menu, allocate units of Enterprise Messaging to your trial subaccount. Within the space in the Cloud Foundry account, You should now be able to see the service listed in the Service Marketplace.
Click on the “Enterprise Messaging” tile and from the Instances menu, create a new instance.
Choose Service Plan - Choose the plan as dev (the only option in the trial environment).Click Next
Specify Parameters. Enter the following JSON. Click Next.
{
"emname": "messaging-promotions",
"options": {
"management": true,
"messagingrest": true
}
}
![](/legacyfs/online/storage/blog_attachments/2020/04/EM_1.png)
Click Next on 'Assign Application' step. Enter any meaningful instance name in the 'Confirm' step and click Finish. You will see the newly created instance with a link to the dashboard.
![](/legacyfs/online/storage/blog_attachments/2020/04/EM-2.png)
You can access the dashboard by clicking the link under 'Actions' or Click on the instance name and choose 'Open Dashboard' in the next screen.
![](/legacyfs/online/storage/blog_attachments/2020/04/EM-3.png)
This will take you to the dashboard of the messaging service. Click on the 'Queues' on the menu.
![](/legacyfs/online/storage/blog_attachments/2020/04/EM-4.png)
Enter a name - 'promotions' and click create.
![](/legacyfs/online/storage/blog_attachments/2020/04/Em-5.png)
You should be able to see the queue created in the dashboard.
![](/legacyfs/online/storage/blog_attachments/2020/04/EM-6.png)
Just one last step before we finish with this service. We need the service keys from the messaging service in order to connect the ' SAP Cloud Platform Functions' with the queues in the messaging service.
Go back to the instance screen. Click 'Service keys'.
Click 'Create Service Key' to generate it.
![](/legacyfs/online/storage/blog_attachments/2020/04/Em-8-2.png)
Note down the entire service key somewhere. We will be using parts of it in Part 4 when we set up the SAP Cloud Platform Functions.