Skip to content

LSEG-API-Samples/Article.EMA.Java.BasicGradle

Repository files navigation

How to Set Up Enterprise Message API Java Application with Gradle

  • version: 1.0
  • Last update: Apr 2023
  • Environment: Windows, Linux
  • Compiler: Java
  • Prerequisite: Demo prerequisite

Introduction

Refinitiv Real-Time SDK (Java Edition) (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 capabilities range from low latency/high-performance APIs right through to simple streaming Web APIs.

The SDK has been released on the Maven Central Repository to support the modern Java development life cycle since the RTSDK Java (formerly known as Elektron SDK) version 1.2. The Maven Central Repository supported also lets SDK compatibilities with the Java build automation tools like Gradle and Apache Maven. This helps Java developers to build RTSDK Java applications, manage its dependencies (Java Developers do not need to manually manage different versions of jar files anymore), and better collaboration in the team.

The RTSDK Java package comes with the Gradle build tool supported by default. However, the included Gradle configuration files are very complex for supporting the SDK multiple APIs (EMA and ETA) and use cases (Core API code, examples, ValueAdd package, etc). If developers want to use Gradle, the RTSDK Java's Gradle settings might not be a good starting point for them.

That is why I am creating this project to show how to use a simple Gradle configuration to work with the EMA Java API. Existing developers who are currently using Gradle also understand how to integrate RTSDK Java into their Gradle project.

Note:

  • This article is based on EMA Java version 3.7.0 L1 (RTSDK Java Edition 2.1.0 L1) and Gradle version 7.3.3 (using Grooy DSL)

Why you need build automation tool

So, I will start off with the reason the Java development teams need the build automation tool. The modern Java build automation tools help developers to automate the software build and project management processes including compiling, dependency manager, packing, and running tests.

If you want to manage the EMA Java application project manually (the old way), you need to manage total 26 jar files (as of April 2023) required by the API as follows:

figure-1

And developers need to add all jar files to the classpath when running the EMA Java application manually like the following example

$>java -cp .;%EMAJ_HOME%\Libs\ema-<version>.jar;%ETAJ_HOME%\Libs\eta-<version>.jar;%ETAJ_HOME%\Libs\etaValueAdd-<version>.jar;%ETAJ_HOME%\Libs\etaValueAddCache-<version>.jar;%ETAJ_HOME%\Libs\etajConverter-<version>.jar;%ETAJ_HOME%\Libs\ansipage-<version>.jar;%BINPAK%\Ema\Libs\apache\commons-configuration2-2.8.0.jar;%BINPAK%\Ema\Libs\apache\commons-lang3-3.9.jar;%BINPAK%\Ema\Libs\apache\commons-logging-1.2.jar;%BINPAK%\Ema\Libs\apache\commons-text-1.9.jar;%BINPAK%\Ema\Libs\xpp3-1.1.4c.jar;%BINPAK%\Eta\Libs\jackson-annotations-2.14.1.jar;%BINPAK%\Eta\Libs\jackson-core-2.14.1.jar;%BINPAK%\Eta\Libs\jackson-databind-2.14.1.jar;%BINPAK%\Eta\Libs\json-20210307.jar;%BINPAK%\Eta\Libs\lz4-java-1.8.0.jar;%BINPAK%\Eta\Libs\ApacheClient\commons-codec-1.11.jar;%BINPAK%\Eta\Libs\ApacheClient\httpclient-4.5.13.jar;%BINPAK%\Eta\Libs\ApacheClient\httpclient-cache-4.5.13.jar;%BINPAK%\Eta\Libs\ApacheClient\httpcore-4.4.13.jar;%BINPAK%\Eta\Libs\ApacheClient\httpcore-nio-4.4.13.jar;%BINPAK%\Eta\Libs\ApacheClient\httpmime-4.5.13.jar;%BINPAK%\Eta\Libs\jose4j\jose4j-0.9.1.jar;%BINPAK%\Eta\Libs\SLF4J\slf4j-1.7.32\slf4j-api-1.7.32.jar;%BINPAK%\Eta\Libs\SLF4J\slf4j-1.7.32\slf4j-jdk14-1.7.32.jar com.refinitiv.ema.examples.training.consumer.series100.ex100_MP_Streaming.Consumer 

The example above is just for running the EMA Java application, the real development project needs to connect to more services, which means the project needs more jar files, configuration files, etc to manage. This makes the development project hard to set up and hard to collaborate among peers.

The build automation tool can help simplify all of this complexity by helping team manage the project dependencies, and standardize project structure with a simple configuration setting as follows:

// tag::dependencies[]
dependencies {
    // This dependency is used by the application.
    implementation 'com.refinitiv.ema:ema:3.7.0.0'
}

And it lets developers compile, run, and test the application easier command.

$> gradlew run

Based on the example above, I think you get the idea of how the build automation tool organizes the project.

Prerequisite

Before I am going further, there is some prerequisite, dependencies, and libraries that the project is needed.

Java SDK

Firstly, you need Java SDK. Please check for the supported Java version from the API Compatibility Matrix page.

I am using the Open JDK version 11 in this project (as of April 2023).

Gradle

Next, the Gradle build automation tool. Please follow Gradle installation guide document.

Gradle Wrapper version 7.3.3

Basically, developers use the Gradle Wrapper to interact with the Gradle build. The Wrapper (gradlew and gradlew.bat) is a script that invokes a declared version of Gradle, downloading it beforehand if necessary.

This project uses the Gradle Wrapper version 7.3.3 (and above). You can check the current Gradle Wrapper version from the following command:

$> gradlew --version

If your Gradle Wrapper is older than version 7.3.3, you can update the Wrapper with the following command:

$> gradlew wrapper --gradle-version=7.3.3

Access to the Refinitiv Real-Time Optimized

This project uses Customer Identity and Access Management (CIAM) (aka Version 2 Authentication) - Client Credentials Grant Model to connect to the Refinitiv Real-Time Optimized (RTO).

Please contact your Refinitiv representative to help you with the RTO account and services.

Note: This is for the CloudConsumer example only.

Access to Refinitiv Real-Time Distribution System

Note: This is for the LocalConsumer example only. Please contact your Market Data team to help you with the Refinitiv Real-Time Distribution System (RTDS).

That covers the project's prerequisite

Development Detail

Please check How to Set Up Enterprise Message API Java Application with Gradle: Development Detail document.

Running the demo applications

My next point is how to run the demo applications. Please see the instructions for each scenario below.

Running the Cloud Consumer application

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

To run the Cloud example, open the project folder in the command prompt and then run the following command:

Version 1 Authentication:

gradlew runCloudConsumer --args="-username $RTO_MACHINEID -password $RTO_PASSWORD -clientId $RTO_CLIENTID -itemName $RIC"

Version 2 Authentication:

gradlew runCloudConsumer --args="-clientId $RTO_CLIENTID_V2 -clientSecret $CLIENTSECRET -itemName $RIC"

figure-2

Running the Local Consumer application

Please contact your Market data team to help you to access the RTDS account and services.

To run the Local example, open the project folder in the command prompt and then run the following command:

gradlew run --args="-service $SERVICE_NAME -itemName $RIC"

Note: The default service name is ELEKTRON_DD.

Conclusion

Now we come to the conclusion of this EMA Java and Gradle article. The RTSDK Java comes with Gradle supported by default. The library is also available in Maven central repository. This makes Java developers can implement the Real-Time application with Gradle or other the build automation tools like Apache Maven, or even the dependency manager tool like Apache Ivy. The tool helps Java developers reduce the complexity of maintaining jar file dependencies, standardized project structure, easily manage the development environment, and support various build processes that match developers' workflow.

When compared to Maven, the Gradle advantages are highly customizable builds, better performance/faster build time, and support for multi-project builds, and developers may prefer Groovy/Kotlin DSL style configuration over the XML file like Maven.

In contrast, the Maven is easier to learn when compared with the Gradle, and has larger documents and resources from both official and user-based websites.

Before I finish, let me just say it is based on the developers' preferences to choose Gradle or Maven (or others) as a main build tool. If the tool supports the Maven central repository, developers can use the RTSDK Java with their project.

References

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

This project shows how to use EMA Java API with the basic Gradle build automation tool

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages