- 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.
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:
- 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).
- Use the RTO version MDWebService as a base application for deploying to Azure Container Instances.
For more detail about the original project information, please check the following resources:
- The original project README file.
- How to build a scalable web service for stock prices article.
- How to deploy a web service on AWS article.
For further details about Migrating a EMA Java API application to Authentication Version 2, please check out the following resource:
- EMA Java API: Refinitiv Real-Time Optimized Version 2 Authentication Migration Guide article.
- Account authorization V1 to V2 migration cheat sheet article.
- Getting Started with Version 2 Authentication for Real-Time - Optimized: Overview article.
This project requires the following dependencies software and libraries.
- Oracle 1.11 & 1.17 or OpenJDK 11.
- Apache Maven project management and comprehension tool.
- Internet connection.
- 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.
- Docker Desktop application.
- Docker Hub repository account.
- Microsoft Azure account.
Please contact your LSEG representative to help you to access the RTO Service account and services.
Please see more detail on the CHANGELOG.md file.
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>
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
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:
Or you can run the HTTP request on the Postman.
That’s all I have to say about how to run the project locally.
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:
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.
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.
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.
Please see more detail on the AZURE.md file.
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:
- Quickstart: Run a custom container in Azure App Services
- Azure Container Apps Overview
- Quickstart: Deploy your first container app using the Azure portal
- Azure App Service vs Azure Container Apps - which to use?
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:
Kudos to Gurpreet Bal for the original version of the MDWebService source code and articles.
For further details, please check out the following resources:
- Real-Time SDK Java page on the LSEG Developer Community website.
- The Real-Time SDK Family page.
- Enterprise Message API Java Quick Start
- Developer Webinar: Introduction to Enterprise App Creation With Open-Source Enterprise Message API
- Developer Article: 10 important things you need to know before you write an Enterprise Real Time application
- Comparing Container Apps with other Azure container options article.
- Changes to Customer Access and Identity Management: Refinitiv Real-Time - Optimized
- How to build a scalable web service for stock prices article.
- How to deploy a web service on AWS article.
- Azure Portal
- Microsoft Learn for Azure website.
- Difference between Azure Container Instances and Azure Container Apps - serverfault post.
- Azure Container Instances Service
- Azure Container Instances documentation
- How to enable TLS for Hasura GraphQL Engine in an Azure Container Instance with Caddy blog post.
- Adding SSL/TLS To Azure Container Instances blog post.
- Enable automatic HTTPS with Caddy in a sidecar container document.
- Enable a TLS endpoint in a sidecar container document.
For any question related to this article or the RTSDK page, please use the Developer Community Q&A Forum.