1. Home
  2. Article Catalog
  3. How to use the Refinitiv Real-Time SDK Docker Images on the Visual Studio Code with the Remote - Containers extension

Article

How to use the Refinitiv Real-Time SDK Docker Images on the Visual Studio Code with the Remote - Containers extension

Wasin Waeosri
Developer Advocate Developer Advocate

Introduction

Visual Studio Code (or just VS Code) is a free source code editor developed and maintained by Microsoft. This cross-platform editor took over developers' popularity based on its fast and lightweight, supports a variety of programming languages with IntelliSense (a feature that borrows from its sibling, Visual Studio IDE), and supports complete development operations like debugging, task running, and version control.

VS Code provides a lot of extensions that extend the editor features and development workflows (Example: the REST Client and Thunder Client testing tools). The editor also supports the remote development that lets you use a container, remote machine, or the Windows Subsystem for Linux (WSL) as a full-featured development environment with the Remote Development Extension Pack.

As part of the Remote Development Extension Pack, the Remote - Containers extension lets developers use a Docker container as a full-featured development environment. It allows the developer to open any folder inside (or mounted into) a container and take advantage of Visual Studio Code's full feature set (IntelliSense, code navigation, debugging, etc) as a local-quality development experience.

This article demonstrates how to use the VS Code Remote - Containers extension with the Refinitiv Real-Time SDK on the Docker platform as example images. Developers can explorer the SDK building system and example codes on the VS Code editor directly.

Note: Please note that the Refinitiv Real-Time SDK isn't qualified on the Docker platform. This article and example projects aim for Development and Testing purposes only. If you find any problems while running it on the Docker platform, the issues must be replicated on bare metal machines before contacting the help-desk support team.

Refinitiv Real-Time SDK Introduction

Refinitiv Real-Time SDK (RTSDK, formerly known as Elektron SDK) is a suite of modern and open source APIs that aim to simplify development through a strong focus on ease of use and standardized access to a broad set of Refinitiv proprietary content and services via the proprietary TCP connection named RSSL and proprietary binary message encoding format named OMM Message.

The SDK source code is available on GitHub, developers can build the RTSDK C++ and Java libraries with the CMake and Gradle build automation tools respectively. If developers are new to the SDK, they can use the following RTSDK Docker images to set up and learn the SDK quickly.

The images have all dependencies and the building system pre-installed. You can check my colleague's Introduction to the refinitivapis/realtimesdk_c Docker Image and Introduction to the refinitivapis/realtimesdk_java Docker Image articles that show a step-by-step guide to deploy and run the RTSDK Docker images via the Docker command line. This article is focusing on accessing the images with VS Code editor.

If you are using the WebSocket API, there is the refinitivapis/websocket_api docker image that contains the latest version WebSocket API Examples too.

Demo prerequisite

This example requires the following dependencies software and libraries.

  1. Visual Studio Code editor.
  2. Docker Desktop/Engine application.
  3. VS Code - Remote Development extension pack
  4. Access to the Refinitiv Refinitiv Data Platform and Refinitiv Real-Time - Optimized. (for the RTO example only)
  5. Internet connection.

I highly recommend you check the extension System requirements and Installation sections to set up your environment.

A devcontainer.json file

The main configuration file that tells VS Code how to access (or create) a development container (aka Dev container) with a well-defined tool and runtime stack is a devcontainer.json file. The dev container configuration is either located under .devcontainer/devcontainer.json or stored as a .devcontainer.json file (note the dot-prefix) in the root of your project.

Note: Make sure to commit a .devcontainer folder to your version control system.

The basic configuration parameters are as follows:

    	
            

// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at:

// https://github.com/microsoft/vscode-dev-containers/tree/v0.202.5/containers/

{

    "name": "RTSDK_Java",

    "image": "refinitivapis/realtimesdk_java:latest",

}

The detail of the configurations above are:

  • name: A display name for the container.
  • image: The name of an image in a container registry that VS Code should use to create the dev container.

The development container lets you pull images from DockerHubGitHub, and Azure Container Registry repositories, and then perform additional tasks such as installing development tools (Git, etc.), installing VS Code extensions, forward ports, set runtime arguments, etc.

The development container is not limited to Docker images, it supports Dockerfile and Docker Compose too. You can build your image(s) to match your development requirements, and then share Dockerfile and/or docker-compose.yml inside a .devcontainer folder (with a devcontainer.json file) to your peer to set up the same development environment.

Please find more details about all devcontainer.json configuration parameters on the VS Code - devcontainer.json reference page.

The RTSDK devcontainer.json file

Let's start with a devcontainer.json file that pulls the refinitivapis/realtimesdk_java from the DockerHub repository.

    	
            

// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at:

// https://github.com/microsoft/vscode-dev-containers/tree/v0.202.5/containers/

{

    "name": "RTSDK_Java",

    "image": "refinitivapis/realtimesdk_java:latest",

    "workspaceFolder": "/opt/refinitiv/Real-Time-SDK/Java",

    "shutdownAction":"stopContainer"

}

The devcontainer.json file above sets the following development properties:

  • name: Using "RTSDK_Java" as a display name of the container.
  • image: Pull "refinitivapis/realtimesdk_java" Docker image from DockerHub https://hub.docker.com/r/refinitivapis/realtimesdk_java URL.
  • workspaceFolder: Sets the default path that VS Code should open when connecting to the container. This devcontainer.json sets the default path to /opt/refinitiv/Real-Time-SDK/Java which is the RTSDK Java package location in the container.
  • shutdownAction: set the VS Code stops the container when the editor window is closed / shut down.

Running the Development Container

You can connect to the container and start developing within it by selecting the Remote-Containers: Reopen in Container command from the VS Code Command Palette (F1).

Alternatively, the VS Code can detect whether there is a folder containing a Dev container configuration file, and then asks you if you want to reopen the folder in a container.

Next, the VS Code window (instance) will reload, pull (or clone) the image, and start building the dev container.

After the build completes, VS Code automatically connects to the container at the path we set to the workspaceFolder property which is the /opt/refinitiv/Real-Time-SDK/Java folder. You can check the VS Code Remote connection status from the button left toolbar.

If you click this toolbar, the VS Code shows the Container Remote connection menu options at the top of the editor.

To close the remote connection, choose the "Close Remote Connection" menu.

Now your VS Code and Dev container are ready to run the RTSDK Java example applications.

Running the RTSDK Java Examples

All files and sub-folders are available in the VS Code explorer. If you open a terminal ( Ctrl+ ` or Ctrl+Shift+ ` - Windows), the current location is /opt/refinitiv/Real-Time-SDK/Java folder too (You can navigate to other locations in the container as well)

The refinitivapis/realtimesdk_java Docker image has built-in all RTSDK Java dependencies and build system, so you can run the SDK examples with the Gradle tool from the VS Code terminal. I am demonstrating with the EMA Java Consumer - Interactive Provider scenario example.

Firstly, open a terminal and run the EMA Java IProvider example 200.

    	
            $>./gradlew runiprovider200
        
        
    

Next, open a new terminal in the same VS Code editor with the  Ctrl+Shift+`  command, and run the EMA Java Consumer example 100.

    	
            $>./gradlew runconsumer100
        
        
    

The results of the EMA Java Consumer - Interactive Provider examples scenario are shown below.

You can run the RTO example, EMA Java ex450_MP_QueryServiceDiscovery with the following command.

    	
            $>./gradlew runconsumer450 -PcommandLineArgs="-username Machine-ID -password RTO-Password -clientId App_Key -itemName <RIC name>"
        
        
    

The result is shown below.

 

If you have your own RTDS server in your environment, you can modify the example code to match your RTDS connection requirement. The following example shows the ex100_MP_Streaming example that has been changed the RTDS server endpoint, service name, and RIC name.

Then, developers can run this example application with the ./gradlew runconsumer100 command.

Please find more details regarding how to run the RTSDK Java examples on the RTSDK Java - Quick Start page.

File Sharing between the Host and Dev Container

Please note that all changes (newly created/modified files and folders) stay in the Dev container as long as the container exists (status Up and Exited). However, if you remove the container (docker rm), that container and its data are destroyed. You can additionally mount points to add to the container when created for sharing files between the host and Dev container with a devcontainer.json's mounts attribute.

    	
            

// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at:

// https://github.com/microsoft/vscode-dev-containers/tree/v0.202.5/containers/

{

    "name": "RTSDK_Java",

    "image": "refinitivapis/realtimesdk_java:latest",

    "workspaceFolder": "/opt/refinitiv/Real-Time-SDK/Java",

    "mounts": ["source=${localWorkspaceFolder}/log,target=${containerWorkspaceFolder}/log,type=bind,consistency=cached"],

    "shutdownAction":"stopContainer"

}

The devcontainer.json file above mounts the current <host workspace location>/log folder to the /opt/refinitiv/Real-Time-SDK/Java/log folder in a container. If the folder does not exist (either host or container), the VS Code automatically creates a folder(s) for you.

Caution: Please note that if you mount a host folder to an existing container folder (example: /opt/refinitiv/Real-Time-SDK/Java), the container folder will be replaced by a host folder.

Please find more details regarding the mounts property from the VS Code - Add another local file mount page.

Adding EMA Java Log

The best scenario to demonstrate this feature is enabling the EMA API log messages to capture the API and HTTP REST activities. You do not need to close the remote-connection before updating the devcontainer.json. You can choose the "Open Container Configuration File" in the remote connection menu to open the current devcontainer.json file.

The current devcontainer.json file will be shown in the VS Code editor, you can add the "mounts": ["source={localWorkspaceFolder}/log,target=localWorkspaceFolder/log,target={containerWorkspaceFolder}/log,type=bind,consistency=cached"] configuration to the file.

Next, choose the "Rebuild Container" from the remote connection menu.

After the re-build completes, VS Code automatically the log folders in the host and /opt/refinitiv/Real-Time-SDK/Java/log folder.

To enable the EMA Java log file, create a Java Logging API logging.properties file in the /opt/refinitiv/Real-Time-SDK/Java/log folder with the following content:

    	
            

.level=FINEST

 

handlers=java.util.logging.FileHandler, java.util.logging.ConsoleHandler

 

java.util.logging.ConsoleHandler.level=FINEST

java.util.logging.ConsoleHandler.formatter=java.util.logging.SimpleFormatter

 

com.refinitiv.eta.valueadd.reactor.RestReactor.level=FINEST

java.util.logging.FileHandler.level=FINEST

java.util.logging.FileHandler.pattern=/opt/refinitiv/Real-Time-SDK/Java/log/ema.log

 

# Format timestamp as date/time with millisecond

java.util.logging.SimpleFormatter.format=%1$tY-%1$tm-%1$td %1$tH:%1$tM:%1$tS.%1$tL %4$-7s %2$s %n%5$s

A logging configuration file sets the EMA API to log all API messages to the /opt/refinitiv/Real-Time-SDK/Java/log/ema.log file.

Finally, run the EMA Java ex450_MP_QueryServiceDiscovery RTO example with the -PvmArgs="-Djava.util.logging.config.file=/opt/refinitiv/Real-Time-SDK/Java/log/logging.properties" argument.

    	
            $>./gradlew runconsumer450 -PcommandLineArgs="-username Machine-ID -password RTO-Password -clientId App_Key -itemName <RIC name>" -PvmArgs="-Djava.util.logging.config.file=/opt/refinitiv/Real-Time-SDK/Java/log/logging.properties"
        
        
    

Then the API activities, HTTP REST messages log messages are stored in the ema.log file, the logging.properties and log files are available in the host machine too.

You can mount other folders to keep the modification codes from the Dev Container back to the host too (note: Do not mount folders to the container existing folders).

Running the RTSDK C++ Image

To run the Dev container with the RTSDK C++ Docker image, you can set a devcontainer.json content to load the refinitivapis/realtimesdk_c from Docker Hub and change the workspaceFolder property to the /opt/refinitiv/Real-Time-SDK/Cpp-C folder as follows.

    	
            

// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at:

// https://github.com/microsoft/vscode-dev-containers/tree/v0.202.5/containers/

{

    "name": "RTSDK_CPP",

    "image": "refinitivapis/realtimesdk_c:latest",

    "workspaceFolder": "/opt/refinitiv/Real-Time-SDK/Cpp-C",

    "mounts": ["source=${localWorkspaceFolder}/log,target=${containerWorkspaceFolder}/log,type=bind,consistency=cached"],

    "shutdownAction":"stopContainer"

}

Then, run the "Remote-Containers: Rebuild and Reopen in Container" command (or "Remote-Containers: Reopen in Container" if you are running the Dev container for the first time). After the build completes, VS Code automatically connects to the container at the path we set to the workspaceFolder property which is the /opt/refinitiv/Real-Time-SDK/Cpp-c folder with all pre-installed dependencies and build system.

You can run the RTSDK C++ example in this Dev Container. If you make some changes to the RTSDK C++ example codes (either ETA or EMA), you can re-build the examples by running a make command in the container /opt/refinitiv/Real-Time-SDK/rtsdk folder.

Please find more details regarding how to run the RTSDK C++ examples on the RTSDK C++ - Quick Start page.

How to run the Examples

The first step is to unzip or download the example project folder into a directory of your choice, then set up RTSDK Java or C++ Docker Dev container in a devcontainer.json file based on your preference.

  1. Start a Docker desktop or Docker engine in your machine.
  2. Open the project folder in the VS Code editor
  3. Install the VS Code - Remote Development extension pack.
  4. Open the VS Code Command Palette with the F1 key, and then select the Remote-Containers: Reopen in Container command.

Now the VS Code editor is ready to run RTSDK Java (or C++) Dev container.

Conclusion and Next Steps

Docker is an open containerization platform for developing, testing, deploying, and running any software application. It helps developers create a consistent development environment without manually maintaining dependencies and toolsets for the project. The VS Code Remote - Containers extension lets developers work with Docker easier by integrating the editor into a Docker container as a full-featured development environment. The extension allows developers to open any folder inside (or mounted into) a container and take advantage of the VS Code rich feature set.

This example project is just a brief introduction to the Remote - Containers extension. Developers can work with Dockerfile and Docker Compose to build a customized Docker image that matches the development requirements, debugging, install various VS Code extensions to use in the Dev Container (via the GUI or configuration file), clone Docker container from Git repositoryattach the VS Code to a running containerport forwarding, and much more. I highly recommend you check the following VS Code resources for more details:

The refinitivapis/realtimesdk_crefinitivapis/realtimesdk_java, and refinitivapis/websocket_api docker images are the good starting points for developers who are new to the Refinitiv Real-Time SDK. Developers can use the Docker image with the Remote - Containers extensions to set up a development environment and run the SDK examples on the VS Code editor with just simple steps.

If you are the developers who are already familiar with Maven, I highly recommend you check the How to deploy and run Real-Time Java Application with Maven in Docker that shows how to use Maven to set up the RTSDK Java development and build environment via Docker

References

For further details, please check out the following resources:

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

GitHub

Refinitiv-API-Samples/Article.RTSDK.Java.Cpp.DevContainer