Skip to Content
Technical Articles

Serverless Extensions – Part 1: Introduction and Set up Enterprise Messaging

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.

 

 

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:

  1. When the promotion is created in the legacy application, it is sent to a queue/topic in the enterprise messaging service.
  2. The Enterprise Messaging service stores the message in the queue/topic.
  3. One or multiple functions can be triggered by the queue/topic and alert their customers through open connectors.
  4. 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:

  1. Once the promotion is created, the extension sends a Whatsapp message to all the registered customers of the chosen customer group.
  2. 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.

 

Serverless Extensions
Part 1 – Introduction and Set up messaging queue in SAP Cloud Platform Enterprise Messaging
Part 2 – Configure SAP Cloud Platform Open Connectors to connect to Whatsapp and Twitter.
Part 3 – Set up SAP Cloud Platform Backend service and connect to APIs from SAP Cloud Platform functions.
Part 4 – Set up functions in SAP Cloud Platform Functions and connect them to the queues and open connectors 
Part 5 – Bring it all together – Testing the extension end to end.

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
	}
}

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.

 

 

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.

This will take you to the dashboard of the messaging service. Click on the ‘Queues’ on the menu.

 

Enter a name – ‘promotions’ and click create.

You should be able to see the queue created in the dashboard.

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.

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.

 

7 Comments
You must be Logged on to comment or reply to a post.
  • Hi,

    great to see an end-to-end scenario showing how these services can play together.

    Small remark – Functions-as-a-Service (Beta) and the Backend-as-a-Service (Beta) will be phased out (they were never available for productive usage – 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)…

    https://help.sap.com/viewer/product/XF_SERVERLESS_RUNTIME/Cloud/en-US

    Martin

  • Great, thanks for your efforts! Only downside is, that the ‘Serverless runtime’ is not yet available on trial… :-(. But everyone already using CPEA or otherwise via SAP Store can directly use it.

    • Thanks, Martin. Any idea about whether Serverless runtime would be made available on trial and when that would be? I can see that it is in very early stages with the amount of documentation I can find for it.

  • Yes, the team is currently working on making it available on trial. Only I cannot provide a reliable date :-(. I hope not too long…

    Nearly all Blogs, examples, … from Functions (Beta) are valid for the new Serverless RT as well. But yes, it is still a new service.

  • Hi Sharadha,

    I like this scenario. What’s the purpose of the Messaging Service here? why not sending it directly through the function and the open connector?

    Best regards,

    Leonardo.

    • Thanks, Leonardo.Though this scenario does not have multiple functions linked to the queue/topic, the Messaging service comes into play when multiple functions are to be triggered by the queue/topic.