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 – Functions as a service
  • SAP Cloud Platform Open connectors
  • SAP Cloud Platform Backend service – Backend as a service


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

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.

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 for ‘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 3 when we set up the SAP Cloud Platform Functions.