Skip to main content
Version: Previous

Request Server - examples

You define your application's Request Server in a kotlin script file called application-name-reqrep.kts.

Below is an example of a reqrep.kts file where the single requestReply code block includes a where clause. You can find out more about where clauses on the Basics page.

requestReplies {
requestReply("INSTRUMENT_DETAILS", INSTRUMENT_DETAILS) {

request {
ALTERNATE_TYPE
}

filterWithParameters {
data.instrumentCode == "ALLL3" &&
genesisSet.getString("ALTERNATE_TYPE") in listOf("RIC", "BLOOMBERG")
}
}
}

Below is a reqrep.kts file that has a fairly simple requestReply codeblock with standard request and reply statements. The where block filters out any data that does not meet the conditions. All data that is returned will have an instrumentCode equal to the request parameter INSTRUMENT_CODE.

requestReplies {
requestReply("INSTRUMENT_DETAILS", INSTRUMENT_DETAILS) {

request {
INSTRUMENT_CODE
}

reply {
INSTRUMENT_CODE
INSTRUMENT_ID
INSTRUMENT_NAME
LAST_TRADED_PRICE
VWAP
SPREAD
TRADED_CURRENCY
EXCHANGE_ID
}

filter {
data.instrumentCode == parameters.getString("INSTRUMENT_CODE")
}
}
}

In the example below, we have modified the example above to include two restrictions:

  • The maximum number of rows to be returned is 5.
  • The process will time out if no response is received for 15 seconds.
requestReplies {
requestReply(INSTRUMENT_DETAILS) {

rowReturnLimit = 5
timeout = 15

request {
ALTERNATE_TYPE withAlias "ALTERNATE_TYPE"
}

reply {
INSTRUMENT_ID
INSTRUMENT_NAME
LAST_TRADED_PRICE
VWAP
SPREAD
TRADED_CURRENCY
EXCHANGE_ID
}
}
}