Sample Instrument Service

In this section you going to learn how to build fully functional instrument service integrating with Vyne.

Getting started

Once you've set-up Vyne locally, we can start building services that can leverage Vyne's automated integration. Vyne is built with Spring Boot, and though it's not a requirement to use spring boot, it's the easiest way to get going.

All the steps below are based on our instrument-service demo project. It contains only what's needed to expose Vyne service so please use it as a template.


  • Java 8
  • Maven 3.x

Configuring Maven pom.xml

Our project will need the following dependencies:

  • io.vyne.vyne-spring - Provides set of annotations enabling spring-boot app communication with Vyne.
  • lant.taxi.taxi-annotation-processor - Based on java annotations generates taxi types/schema that will be deployed to Vyne.
  • spring-boot-starter-web - This will allow us to build REST endpoints.
  • spring-cloud-starter-netflic-eureka-client - This will register service with eureka discovery service.





        <!-- Provides set of annotations enabling spring-boot app communication with Vyne. -->
        <!-- Based on java annotations generates taxi types/schema that will be deployed to Vyne. -->
        <!-- This will allow us to build REST endpoints. -->
        <!-- This will register service with eureka discovery service. -->


Vyne and Taxi artefacts are not deployed to maven public repo, hence the need to custom repositories section:



Our project uses kotlin, so we going to use kotlin-maven-plugin to build it and to generate taxi types.



Note: taxi-annotation-processor is a processor generating taxi-types based on annotations in your code.

Generated code can be found in target/generated-source/kaptKotlin/compile.

Creating instrument service

Spring boot main

First step is to create typical spring boot app with two extra Vyne and Eureka annotations. This will enable communication with Vyne schema server and Eureka service discovery.

@VyneSchemaPublisher(publicationMethod = SchemaPublicationMethod.DISTRIBUTED)
open class InstrumentServiceApp {
    companion object {
        fun main(args: Array<String>) {
            // Register Instrument service taxi types in Vyne.

            // start spring boot app
            SpringApplication.run(InstrumentServiceApp::class.java, *args)

Spring boot config

Below you'll find example of how to Configure Eureka discovery service and Vyne schema. This is required for vyne to be able to discover your service and call it. It also need a name and the version.

    name: instrument-service

  port: 9402

    registryFetchIntervalSeconds: 1
    initialInstanceInfoReplicationIntervalSeconds: 5
      defaultZone: ${eureka.uri}/eureka/
    leaseRenewalIntervalInSeconds: 2
    leaseExpirationDurationInSeconds: 5
    # this is enabling vyne running in docker to call service running in your IDE
    preferIpAddress: true

    name: ${spring.application.name} # Name of the app exposed to Vyne
    version: 0.1.0 # Version of the app exposed to Vyne 

Defining Taxi Types

Our service needs to define model (Taxi types) discover-able through Vyne. This can be done simply by annotating your pojo objects with Taxi Annotations.

data class Instrument(
        val isin: Isin,
        val name: LegalEntityName,
        val symbol: Symbol,
        val countryCode: CountryCode

typealias Isin = String

typealias LegalEntityName = String

typealias Symbol = String

typealias CountryCode = String

Now, to generate taxi types you have to execute maven command:

mvn compile

After that your IDE should pick TypeAliases dependency.

Exposing REST endpoints

Now when we got the types we can create REST endpoints. In our example we going to expose two endpoints:

  • listing all instruments,
  • looking up for instrument by ISIN.
class InstrumentService {
    private val instruments = listOf(
            Instrument("US0378331005", "Apple", "AAPL", "USA"),
            Instrument("US02079K1079", "Alphabet C (ex Google)", "GOOG", "USA"),
            Instrument("GB00B03MLX29", "Royal Dutch Shell A", "RDSA", "UK")

    fun getInstrument(@PathVariable("isin") isin: Isin): Instrument {
        return instruments.first { it.isin == isin }

    fun getAllInstruments(): List<Instrument> {
        return instruments

Starting instrument service

For this step to work we need a running Vyne instance. If you don't have it please follow instructions of how set-up Vyne locally.

For the app to connect to Vyne we need to specify hazelcast.config location (refer to set-up Vyne locally)

This is to allow your app to join the Hazelcast cluster created by Vyne.

Open command line prompt and navigate to your demo app, e.g.

cd ...demo/finance/instrument-service

and type in the following maven command:

mvn spring-boot:run -Dspring-boot.run.jvmArguments="-Dhazelcast.config=../../vyne-docker-stack/hazelcast.yml"

Before starting the app append this system property


If everything went smoothly you should see in the console log no exceptions and the following statement:

Members {size:2, ver:14} [
        Member []:5701 - d9fe0048-8df2-47b1-8c6b-b26c66eab0ae
        Member []:5702 - 20836466-429d-46b9-a49d-7af1c7dbc6fd this

This means your app successfully joined Vyne cluster.


Vyne schema-explorer

Vyne schema-explorer shows all the services discover-able through Vyne.

When you navigate to http://localhost:9022/schema-explorer you should see:

  • instrument-service,
  • version 0.1.0 (as defined in application.yml),
  • all our taxi types,
  • two REST endpoints.


Vyne offers couple of ways of querying, for a full list refer to Query Api section.

Querying all instruments

Vyne UI offers an easy way for testing your services. To query for all the instruments:

In the result you can see all the instruments defined by your service, the endpoint /instruments and how long it took to call that endpoint.

Looking up instrument by ISIN

Same as before navigate to http://localhost:9022/query-wizard and

  • click 'Add new fact' button
  • paste Isin value 'US0378331005' (Apple)
  • select type to discover 'demo.Instrument'
  • click 'Submit query' button

As you can see this time different endpoint was used to discover that data /instrument/{isin}, and only single instrument representing 'Apple' stock was returned.



In this section you have learned to build:

  • sample instrument service,
  • how to connect to vyne,
  • how to query your service.