Skip to content

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

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Develop with Refinitiv Real-Time SDK Docker Image in VS Code Using the Remote - Containers extension

  • version: 1.0.1
  • Last update: March 2022
  • Environment: Docker
  • Compiler: Java, C/C++
  • Prerequisite: Demo prerequisite

Introduction

Visual Studio Code (or just VS Code) is a free source code editor developed and maintained by Microsoft. This cross-platform editor rapidly gained popularity with developers as it is fast and lightweight, supports a variety of programming languages with IntelliSense (a feature that has originated with VS Code’s older sibling, Visual Studio IDE), and enables complete development operations like debugging, task running, and version control.

VS Code provides numerous extensions that add features and expand development workflows (Example: the REST Client and Thunder Client testing tools). VS Code 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.

figure-1

This article demonstrates how to use VS Code Remote - Containers extension with the Refinitiv Real-Time SDK Docker images. Developers can explore the RTSDK, build and run the provided examples codes directly in VS Code IDE.

Note: Please note that the Refinitiv Real-Time SDK isn't qualified for the Docker platform. This article and example projects are intended for development and testing purposes only. If any problems are found while running the example code with RTSDK on with Docker platform, the suspected issues must be reproduced on a bare-metal machine prior to contacting the Refinitiv 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, C/C++ and Java respectively. If developers are new to the SDK, they can use the following RTSDK Docker images to set up and learn the SDK quickly.

These images include all required dependencies and come with the build scripts and tools. You can check my colleague's Introduction to the refinitivapis/realtimesdk_c Docker Image and Introduction to the refinitivapis/realtimesdk_java Docker Image articles for step-by-step guidance on how to deploy and run the RTSDK Docker images via Docker command line. This article focuses on accessing RTSDK docker images from VS Code.

If you are using the WebSocket API, there is refinitivapis/websocket_api docker image that contains the latest version of 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 following 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 named devcontainer.json file. The dev container configuration is either located under .devcontainer/devcontainer.json or stored as in a file named .devcontainer.json file (note the dot-prefix) in the root of the project.

figure-2

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

Let me explain these configurations:

// 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 DockerHub, GitHub, and Azure Container Registry repositories, and then perform additional tasks such as install development tools (Git, etc.), install 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) with your colleagues to help them 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 by creating 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

Docker Desktop/engine should be running prior to the next step.

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).

figure-3

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.

figure-4

Next, the VS Code window (instance) will reload, pull (or clone) the image, and start building the dev container. Please note that if the image already a

figure-5

There may be a message “Extension Pack for Java is recommended for this repository.” At this point, may be good to install the Extension for Java, as we intend to use RTSDK Java.

Once this 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.

figure-6

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

figure-7

To close the remote connection, choose the "Close Remote Connection" from the drop-down menu.

Project files

This example project contains the following files and folders

  1. .devcontainer/devcontainer.json: An example development container configuration file.
  2. images: Project images folder.
  3. LICENSE.md: Project's license file.
  4. README.md: Project's README file.
  5. RTSDK_DevContainer.md.md: Project's Document file.

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.

figure-3b

Now VS Code is ready to run RTSDK Java (or C++) Dev container. Please see the full details over the RTSDK and VS Code Dev Container integrations on the RTSDK_DevContainer.md file.

running-demo

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 makes developers work with Docker easier, by integrating VS Code 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’s 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 repository, attach the VS Code to a running container, port forwarding, and much more. I highly recommend you check the following VS Code resources for more details:

The refinitivapis/realtimesdk_c, refinitivapis/realtimesdk_java, and refinitivapis/websocket_api docker images are 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, that makes running RTSDK examples in VS Code.

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 an RTSDK Java development environment in a Docker container.

References

For further details, please review the following resources:

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

Developers Articles

About

This example project shows how to use the RTSDK Docker images with the VS Code Remote Containers extension to developer inside the container with the VS Code.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published