Elektron SDK - Java

API Family: Elektron

EMA Consumer - Creating a barebones EMA consumer application

Download tutorial source code

Click here to download

Last update May 2018
Environment Windows, Linux
Compilers JDK 1.7 or greater
Prerequisite Quick Start Guide

Introduction

The goal of this tutorial is to define a basic EMA shell interface preparing us to consume realtime market data. Based on this shell interface, we will walk through the general steps within subsequent tutorials to demonstrate the ability to request for market data and to process and parse the realtime responses. To support these goals, we must first establish an appropriate build environment to successfully build and run our series of tutorials.

Description

For these tutorials, it is helpful to familiarize yourself with the contents of the EMA package. The EMA components are packaged as part of the Elektron SDK stack providing ease-of-use capabilities with a number of value added features simplifying application development.  To demonstrate this, EMA includes a number of examples focusing on multiple capabilities geared towards simplicity. These tutorials are based on specific features related to the streaming of market data items.

Tutorial Steps

The following steps will outline how to define a build environment, implement a shell interface that defines the structure of a basic EMA Consumer, build and run the example successfully.

Establish an EMA build environment

The series of tutorials come packaged with 2 convenient scripts: buildConsmer and runConsumer - see Build and Run below for more details. Because EMA can be installed anywhere within your environment, our build and run scripts make an assumption about how to resolve the location of EMA's JAR packages. While there are multiple ways to configure setup, this project assumes the following:

  • Elektron SDK for Java Home directory

    The environment variable ELEKTRON_JAVA_HOME is used within build and run scripts to resolve the location of your Elektron SDK installation. Defined for both the Windows and Linux scripts, this will allow developers to easily copy/duplicate projects to other members and to themselves without having to re-define directory locations within their own projects.
  • Java build environment

    The environment variable JAVA_HOME is used within the build and run scripts to resolve the location of your Java environment required to compile and run the tutorials.

Alternatively, you can modify the scripts to refer to your installation if you choose not to define environment variables.  The scripts refer to these references at the top of the files.  Once set up, future tutorials will work without further configuration.

Implementation Overview - Shell code for EMA setup

The basic shell utilizes a single source file basicConsumer.java containing the basicConsumer class. This class represents the main interface between our consumer and the Elektron SDK. EMA utilizes an event-driven, asynchronous model when communicating with a Refinitiv Market Data system. To support this event driven communication, consumer applications must define a class that implements the OmmConsumerClient EMA interface. This interface declares a number of methods, or callbacks, used to handle the different types of communication events coming from the Refinitiv Market Data system.

At this stage of the tutorial, the basicConsumer class, is just a shell framework that defines empty callback methods. They will be implemented in subsequent tutorials:

						public class basicConsumer implements OmmConsumerClient
{
	//*************************************************************************************************
	// Callback methods required by the OmmConsumerClient Interface.
	//
	// The following methods allow us to capture realtime events such as status and data events.  The
	// relevant events will be implemented and described in subsequent tutorials.
	//*************************************************************************************************
	public void onRefreshMsg(RefreshMsg refreshMsg, OmmConsumerEvent event){}
	public void onUpdateMsg(UpdateMsg updateMsg, OmmConsumerEvent event){}
	public void onStatusMsg(StatusMsg statusMsg, OmmConsumerEvent event){}	
	public void onAllMsg(Msg msg, OmmConsumerEvent consumerEvent){}
	public void onAckMsg(AckMsg ackMsg, OmmConsumerEvent consumerEvent){}
	public void onGenericMsg(GenericMsg genericMsg, OmmConsumerEvent consumerEvent){}
   
    ...
}	

			

The above structure outlines the 6 mandatory callbacks required by the OmmConsumerClient interface. Each callback will be described in subsequent tutorials but all serve the purpose of capturing realtime events such as changes in the market, based on the requested data of interest. 

Build and run

The package includes convenient scripts to build and run the tutorials.  Note: If you are using version ESDK 1.1.x or lower, you will need to utilize the scripts located within the build-1.1.x subdirectory.

For this series of tutorials:

To Build a specific tutorial:

  • > buildConsumer.bat [<1|2|3|4|5>] - Windows
  • > sh buildConsumer.ksh [<1|2|3|4|5>] - Linux

To Run a specific tutorial:

  • > runConsumer.bat <1|2|3|4|5> - Windows
  • > sh runConsumer.ksh <1|2|3|4|5> - Linux

Eg (Windows):

> buildConsumer 1 

Building tutorial 1...

Done.



> runConsumer 1

Running this tutorial will simply echo a start and complete message indicating success.  In the next tutorial, we setup an EMA Consumer to allow us to request for a market data instrument and display the results.

				Running tutorial 1...
Processing complete
			

References

To learn more about EMA please refer to the

Tutorial Group: 
EMA Consumer