Skip to content

The code for Webservice developed using RTSDK and Spring Boot framework, fork to RTO connection and aims to deploy on Azure.

License

Notifications You must be signed in to change notification settings

LSEG-API-Samples/Article.EMA.Java.RTO.Azure

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

How to Deploy EMA RTO Application to Azure

  • Last Update: June 2024
  • Compiler: Java, Docker, and Maven
  • Prerequisite: RTO Authentication Version 2 credential

Example Code Disclaimer: ALL EXAMPLE CODE IS PROVIDED ON AN “AS IS” AND “AS AVAILABLE” BASIS FOR ILLUSTRATIVE PURPOSES ONLY. REFINITIV MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY KIND, EXPRESS OR IMPLIED, AS TO THE OPERATION OF THE EXAMPLE CODE, OR THE INFORMATION, CONTENT, OR MATERIALS USED IN CONNECTION WITH THE EXAMPLE CODE. YOU EXPRESSLY AGREE THAT YOUR USE OF THE EXAMPLE CODE IS AT YOUR SOLE RISK.

Introduction

Let’s start with purpose of this project repository. This repository is forked from my colleague How to build a scalable web service for stock prices with the following goals:

  1. Update my colleague's Spring Boot MDWebService to support the Real-Time Optimized (RTO, not a Wealth solution products) with the Authentication Version 2 (aka Customer Identity and Access Management - CIAM, or Service Account).
  2. Use the RTO version MDWebService as a base application for deploying to Azure Container Instances.

figure-1

For more detail about the original project information, please check the following resources:

For further details about Migrating a EMA Java API application to Authentication Version 2, please check out the following resource:

Prerequisite

This project requires the following dependencies software and libraries.

  1. Oracle 1.11 & 1.17 or OpenJDK 11.
  2. Apache Maven project management and comprehension tool.
  3. Internet connection.
  4. Access to the Real-Time Optimized (Not Wealth products) with Authentication Version 2 (aka Customer Identity and Access Management - CIAM, or Service Account). The Service Account is Client ID and Client Secret.
  5. Docker Desktop application.
  6. Docker Hub repository account.
  7. Microsoft Azure account.

Please contact your LSEG representative to help you to access the RTO Service account and services.

What I have changed from the original project

Please see more detail on the CHANGELOG.md file.

How to run MDWebService with RTO connection

My next point is how to set up the project for the RTO connection. Firstly, set a application.properties file to connect to RTO as follows:

#Choose connection mode RTDS or RTO
MarketData.ConnectionMode=RTO

Next, create a .env file in a MDWebService folder with the Authentication Version 2 credential like the following format:

#Authentication V2
CLIENT_ID=<Your Auth V2 Client-ID>
CLIENT_SECRET=<Your Auth V2 Client-Secret>

Finally, set the prefer RTO endpoint region in the Location configuration node of the EmaConfig.xml file.

<ChannelGroup>
 <ChannelList>
  <Channel>
   <Name value="Channel_RTO"/>
   <ChannelType value="ChannelType::RSSL_ENCRYPTED"/>
   <CompressionType value="CompressionType::None"/>
   <GuaranteedOutputBuffers value="5000"/>
   <!-- EMA discovers a host and a port from RDP service discovery for the specified location
				 when both of them are not set and the session management is enable. -->
   <Location value="ap-southeast"/>
   <EnableSessionManagement value="1"/>
   <ObjectName value=""/>
  </Channel>
 </ChannelList>
</ChannelGroup>

Run with Java Locally

Now let me move on to how to run the project locally for testing. Once the RTO configurations above have been setup, use the following command to compile and package the file as a single executable jar file. (Note the use of Maven wrapper here):

mvnw clean package
#or
mvn clean package

Once the compilation is successful and a jar file has been created in the target directory, use either of the following commands to run the application locally:

mvnw spring-boot:run
#or
java -jar target\MDWebService-0.0.1-SNAPSHOT.jar
#or
mvn spring-boot:run

figure-2

The ChannelUp message from EMA informs the application that it has successfully connected to the RTO server on port 14002.

Once the application is running and successfully connected to the market data system, navigating to the web URL of http://server:port/quotes/JPY=,THB=,SGD= should produce a JSON response like this:

figure-3

Or you can run the HTTP request on the Postman.

figure-4

That’s all I have to say about how to run the project locally.

Run with Docker

So, now let’s look at how to run the project with Docker which is one of the main target of this project. Firstly, build the container image by issuing the command (a Dockerfile is available in the MDWebService folder):

docker build -t mdwebservice-rto .

This will compile the image for our container. The newly created image can be seen with the docker images command:

Note: Please note that the Real-Time SDK isn't qualified on the Docker platform. If you find any problems while running it on the Docker platform, the issues must be replicated on bare metal machines before contacting the helpdesk/Real-Time APIs support.

This will compile the image for our container. The newly created image can be seen with the docker images command:

figure-5

Then created image can be run using the command:

docker run -it --rm -p 8080:8080 --env-file .env mdwebservice-rto

Here, we have run the container to connect to RTO. The container also binds the port 8080 used by Tomcat on to our local machine. The application can be tested by navigating to the 8080 port as done previously.

figure-6

After successful test, stop the running container using the docker stop command:

docker ps -a
docker container stop <container_id>

That’s all I have to say about how to run the project with Docker.

How to run MDWebService with RTDS connection

Firstly, set a application.properties file to connect to RTDS as follows:

#Choose connection mode RTDS or RTO
MarketData.ConnectionMode=RTDS

Next, follow the steps on the original project.

How to deploy to Azure Cloud Service

Please see more detail on the AZURE.md file.

figure-7

figure-8

figure-9

Next Steps

That brings me to the end of this project. The step-by-step guide on this project just shows the easiest way to deploy and host your web application container on Azure cloud service as a test scenario. However, there more tasks to do if you need to deploy your production container like the following:

  • Adding the SSL to your deployment for enabling the secure HTTPS connection
  • Set up the load balancer and availability zone to handle more consumers traffics and for resiliency.
  • Define CI/CD process for the next deployment.
  • And much more.

About adding the SSL to Azure Container Instance App, there are various way to add SSL to Container Instances such as, Enable automatic HTTPS with Caddy in a sidecar container, Enable a TLS endpoint in a sidecar container.

There are also other Azure Container services like Azure App Service or Azure Container Apps that supports automatic scalability, more advanced network control/configurations, easy to connect to other Azure services, and built-in SSL supported. They are the service that I will be explored with our LSEG APIs in the future.

To learn more about the Azure App Services and Container Apps, please check the following resources:

Meanwhile, the open-source nature of the RTSDK makes the SDK easy to deploy on the Cloud Service. With the EMA API, you can create a Real-Time application with ease-of-use interfaces and easy to integrate with other services.

For more detail about the Real-Time SDKs, please check the following resources:

Special Thank

Kudos to Gurpreet Bal for the original version of the MDWebService source code and articles.

Reference

For further details, please check out the following resources:

For any question related to this article or the RTSDK page, please use the Developer Community Q&A Forum.

About

The code for Webservice developed using RTSDK and Spring Boot framework, fork to RTO connection and aims to deploy on Azure.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Java 94.7%
  • Dockerfile 5.3%