As explained in the previous blog, the multi-tenant application will be deployed and run in the provider account (see section below highlighted in red).


Robert from ITeLo Consulting is the administrator of this account so he will perform the following steps in order to setup the application in the ITeLO Consulting (Provider) account.

Step 1: Create an application archive that contains all the application artifacts
Step 2: Deploy the application archive into the ITeLO Consulting (Provider) account
Step 3: Create subscriptions from consumers ABC PetroCorp and XYZ EnergyCorp to the applications running in the provider account

Let’s look at these steps in detail.
Pre-requisites:

  1. You have Java 7 installed.
  2. You have Eclipse Neon with HCP tools/plugins installed.
  3. You have the latest version of HCP Java Web SDK downloaded and unzipped.
  4. Note that this series requires creation of multiple HCP accounts and therefore cannot be done using the developer trial account.
  5. You have an HCP account which has a database assigned to it. For this blog series, we expect the display name of the HCP account to be ITeLO Consulting (Provider).
  6. The ITeLO Consulting (Provider) account has at least one unused Java Compute Unit assigned to itself from the quota.

Note: You could refer to the Getting Started with HCP tutorials for more information.

Note: In this blog, we make use of a great new feature called Solutions deployment that is currently in Beta. Read more about how to enable Beta features & also the terms of usage associated here.

As an alternative, you could also just do a deployment of individual applications instead of using the Solutions feature.

Step 1: Create an application archive that contains all the application artifacts

For this blog series, the source code for the Pollution Monitoring application has been shared in GitHub. We will first clone the application source code and then create the application archive from the source code.

Clone the source code from GitHub repository

Step Screenshot
a) Clone this Git repository and import the project into the Eclipse workspace.
Note: The pre-requisite for this step is that EGit Plugin must be installed in Eclipse.
b) After a successful import, the Project Structure should look like this

A real world application comprises of multiple modules developed using different technologies.  The modules would also need to be deployed to different target runtimes (e.g. Java, HTML5). Instead of creating, deploying and managing these modules individually, HCP supports creation of a single Multi-Target Application that packages all these heterogeneous modules into a single archive.

As explained in the architecture overview from the previous blog , the business logic is defined in the Java application and UI logic is defined in an HTML5 application. In this step, Robert will build a multi-target application (MTA) Archive file in order to package the application into a deployable format.

Create (multi-target) application archive

Step Screenshot
a) Modules of the multi-target application are described in the MTA deployment descriptor file (mtad.yaml). Open this yaml file that is present under Java Resources ->resources folder.
Note: Maven setup is a pre-requisite for this step
 

b) The yaml file contains information about the Java and HTML5 modules that should be created. (We’ll provide more details in the MTAR Explanation section at the end of the blog).For now, bind the database (using the database ID) to the Java application.

Here, the id is the DB identifier (ID) of the database assigned to the provider account.

 

Refer to the DB ID under the Persistence -> Databases Systems tab in the ITeLO Consulting (Provider) account.

c) Trigger the Maven build by selecting the project and choosing Run as ‘Maven Build…’
(The application archive file will be generated using Eclipse Maven build).
d) Specify “clean install package” as Goals in the Run configuration of Maven build as shown in the snapshot.
e) Once project is successfully built, the following message will be displayed in the console
f) Trigger the Eclipse project update as shown in the snapshot.
g) The pollutionmonitoring.mtar (MTA Archive) file would be generated under the target folder as shown the snapshot.

 

Step 2: Deploy the application archive into the ITeLO Consulting (Provider) account

The next step is to deploy the pollutionmonitoring.mtar MTA Archive file into the ITeLO Consulting (Provider) account. This is done using the Solutions (BETA) feature shown in the HCP Cockpit as described here.

Step Screenshot

a) Click on the Solutions (BETA) tab in the HCP cockpit

b) Click on the Deploy button.

c) In the Browse button of the Deploy dialog, select the MTAR file location that was generated from the Maven build.

d) Choose Deploy.

e) Once the MTA archive file is successfully deployed, you can observe the following in the HCP cockpit.

  • A Java application ‘pollutionmonitoring’ would be deployed and running under the Java application pane
  • A data source binding would be created under Data Source Bindings pane of Java application
  • An HTML5 application ‘pollutionmonitoringui’ would run under HTML5 pane of the provider account.

 

Step 3: Create subscriptions from consumers ABC PetroCorp and XYZ EnergyCorp to the applications running in the provider account

 

In this step, Robert would create 2 consumer accounts – by name ABC Petro Corp (Consumer) and XYZ Energy Corp (Consumer).

Create consumer accounts

Step Screenshot
a) Navigate to the Overview tab of the HCP account.
b) Click on the ‘New Account’ button as shown in the screenshot.

c) Create an account by the nameABC Petro Corp (Consumer)

d) Click on Save.

e) Similarly, create the accountXYZ Energy Corp (Consumer)”.

f) From the overview pane for the global account, there would be 3 accounts shown

As the next step, Robert will subscribe these consumer accounts to the Java and HTML5 applications running on the provider account.

Create subscriptions to the applications running in the provider account

Step Screenshot

Note:A prerequisite for executing neo commands is setting up the console client.

a) Using the neo console client, a subscription is created from the ABC Petro Corp (Consumer) account to the pollutionmonitoring Java application running in the ITeLO Consulting (Provider) account.

neo subscribe –account <<ABC_PetroCorp_consumer_account_id>> -application <<ITeLO_consulting_provider_account_id>>:pollutionmonitoring -user <<your_user_id>> -host <<your_landscape_host>>

 

 

 

b) Similarly a subscription has to be created to the pollutionmonitoringui HTML5 application in the ITeLO Consulting (Provider).

Click on the Subscriptions tab, then select “New Subscription”

c) Select the provider account and application as shown in the screenshot.

d) Then click on Save.

e) This would create a subscription to the HTML5 application.

f) In the Subscriptions tab of ABC PetroCorp(Consumer) account, you would see the following subscriptions.
g) Similarly, subscriptions have to be created for XYZ Energy Corp (Consumer) as summarized in the table.
Subscriber Provider application
ABC Petro Corp (Consumer)

ITeLO Consulting (Provider) : pollutionmonitoring

{Java app}

ABC Petro Corp (Consumer)

ITeLO Consulting (Provider) : pollutionmonitoringui

{HTML5 app}

XYZ Energy Corp (Consumer)

ITeLO Consulting (Provider) : pollutionmonitoring

{Java app}

XYZ Energy Corp (Consumer)

ITeLO Consulting (Provider) : pollutionmonitoringui

{HTML5 app}

MTAR Explanation

Now let’s understand how the MTAR was created in Step 2. The required configuration was specified in 2 files – the MTA Deployment descriptor file (mtad.yaml) and the pom.xml file.

  • MTA Deployment Descriptor file: Modules of the multi-target application are described in the MTA deployment descriptor file (mtad.yaml).
    • HTML5 module is defined below by specifying the module name, type and dependency (to the Java application that contains the business logic).
    • Java module is defined below by specifying the module name, type and dependency (to the database service that will persist data generated by the Java application).
    • HCP persistence service is configured with the ID of the database that is assigned to the HCP account.   
  •  pom.xml file:It contains following configuration details used by maven to build the MTA Archive file.


     

a)

This attaches Assembly.xml file (which is defined under Java Resources ->resources folder) which generates pollutionmonitoring.jar file.

It also generates entries in MANIFEST.MF file that specify information about Java and HTML5 binaries modules in the pollutionmonitoring.jar file.

b)

This configuration will finally move pollutionmonitoring.jar into pollutionmonitoring.mtar MTA Archive file.

After a successful Maven build, the pollutionmonitoring.mtar (Multi Target Application Archive) file would contain:

  • zip (HTML5 module)
  • war (Java module)
  • yaml (MTA deployment descriptor file)
To report this post you need to login first.

3 Comments

You must be Logged on to comment or reply to a post.

  1. J. Jansen

    Hi guys, great blog series. In the Itelo case, a Java multitenant application is used, but would this architecture also be valid for MTA’s running on the Cloud Foundry based runtimes as well? So for instance NodeJs?

    Kind regards,

    Jeroen

    (0) 
  2. Gregor Wolf

    Hi Ashitha,

    thank you for this introduction into the creation of Multi-Tennant Applications in SAP CP.

    I would suggest that you update the neo subscribe command. When using the full parameter names you need two dashes (–) instead of just one (-). Perhaps you update the formatting and use a code sample like:

    --

    Best regards
    Gregor

    (0) 

Leave a Reply