question

Upvotes
Accepted
3 1 1 1

We are faicng error while using EMA Code : error: type mismatch. Please assist

We are using decode function as is mentioned in the website in REPL mode


import com.thomsonreuters.ema.access.Data

import com.thomsonreuters.ema.access.DataType;

import com.thomsonreuters.ema.access.DataType.DataTypes

import com.thomsonreuters.ema.access.EmaFactory

import com.thomsonreuters.ema.access.FieldEntry

import com.thomsonreuters.ema.access.FieldList


def decode(fieldList: FieldList){

fieldList.forEach( fieldEntry => { print("\tFid: " + fieldEntry.fieldId() + " Name: " + fieldEntry.name() + " DataType: " + DataType.asString(fieldEntry.load().dataType()) + " Value: ")

})

}


but it throws error as below for highlighted part.


<console>:85: error: missing parameter type.


We tried multiple approaches but no luck.


def decode(fieldList: FieldList){

fieldList.forEach( (fieldEntry:FieldEntry) => { print("\tFid: " + fieldEntry.fieldId() + " Name: " + fieldEntry.name() + " DataType: " + DataType.asString(fieldEntry.load().dataType()) + " Value: ")

})

}


<console>:86: error: type mismatch;

found : com.thomsonreuters.ema.access.FieldEntry => Unit

required: java.util.function.Consumer[_ >: com.thomsonreuters.ema.access.FieldEntry]

{ fieldList.forEach( (fieldEntry:FieldEntry) => { print("\tFid: " + fieldEntry.fieldId() + " Name: " + fieldEntry.name() + " DataType: " + DataType.asString(fieldEntry.load().dataType()) + " Value: ")


elektronrefinitiv-realtimeelektron-sdktreprrtema-apielektron-message-api
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Upvotes
Accepted
14.7k 39 12 18

Hi @ashwathguru.s,

You can follow the decode example as shown in the samples packaged with SDK like - series200\example200__MarketPrice__Streaming\Consumer.java, or follow the step by step EMA Java decoding tutorial.

If there is still an issue, please post you complete code and we can take a peek at it. Thanks.

icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Upvotes
3 1 1 1

Hi,


We are using Scala. The code we are referring is mentioned here


https://developers.refinitiv.com/article/get-real-time-market-data-using-ema-java-scala-language


As mentioned, decode(fieldList: FieldList) is failing with given error.


We are running this in scala interpreter and trying to run forEach loop to extract each single field and use it for further purpose.



class AppClient extends OmmConsumerClient {

def onRefreshMsg(refreshMsg: RefreshMsg,event: OmmConsumerEvent) {

println("Refresh Message of: " +

(if (refreshMsg.hasName()) refreshMsg.name()

else "<not set>"))

println("Service Name: " +

(if (refreshMsg.hasServiceName()) refreshMsg.serviceName()

else "<not set>"))

println("Item State: " + refreshMsg.state());

//println(refreshMsg)

val a = refreshMsg.payload().fieldList().size

println(a)

decode(refreshMsg.payload().fieldList())

}

def decode(fieldList: FieldList){

fieldList.forEach((fieldEntry:FieldEntry) => {

print("\tFid: " + fieldEntry.fieldId() + " Name: " + fieldEntry.name() + " DataType: " + DataType.asString(fieldEntry.load().dataType()) + " Value: ")

})

}


def onUpdateMsg(updateMsg: UpdateMsg,event: OmmConsumerEvent) {

println("Update Message of: " +

(if (updateMsg.hasName()) updateMsg.name()

else "<not set>"))

println("Service Name: " +

(if (updateMsg.hasServiceName()) updateMsg.serviceName()

else "<not set>"))

println(updateMsg)

}

def onStatusMsg(statusMsg: StatusMsg,event: OmmConsumerEvent) {

println("Status Message of:" +

(if (statusMsg.hasName()) statusMsg.name()

else "<not set>"))

println("Service Name: " +

(if (statusMsg.hasServiceName()) statusMsg.serviceName()

else "<not set>"))

if (statusMsg.hasState())

println("Item State: " + statusMsg.state())

println()

}

def onGenericMsg(genericMsg: GenericMsg,event: OmmConsumerEvent) { }

def onAckMsg(ackMsg: AckMsg,event: OmmConsumerEvent) { }

def onAllMsg(msg: Msg,event: OmmConsumerEvent) { }

}


var myapp = new AppClient

var consumer: OmmConsumer = null

val appClient: AppClient = new AppClient()

val config: OmmConsumerConfig = EmaFactory.createOmmConsumerConfig()

consumer = EmaFactory.createOmmConsumer(config.host("test").username("test"));

val reqMsg = EmaFactory.createReqMsg();

var itemNames: scala.collection.mutable.Set[String] = Set("INR=")

var domainType: Int = EmaRdm.MMT_MARKET_PRICE

consumer.registerClient(reqMsg.serviceName("test").domainType(domainType).name(itemNames.head), appClient)

icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Upvotes
14.7k 39 12 18

Are you using Consumer.scala sample without any modifications?

@Pimchaya.Wongrukun can you please help with this code snippet.

icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Upvotes
9.5k 10 5 7

Hello @ashwathguru.s

You can see an example of EMA Consumer in the Scala language from this article.

icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Upvotes
9.5k 10 5 7

Hello @ashwathguru.s

Based on your given source code, I have tested it with Elektron SDK 1.5.0.L1 and it worked properly without any problem. The complete source code is ConsumerClient.txt, please try it with Elektron SDK 1.5.0.L1

If the problem still occurs with my given source code and Elektron SDK 1.5.0.L1, please share the following info:

  1. EMA xml trace log when the problem occurs. EMA will trace sent and received message between EMA and the server when set XmlTraceToStdout in Consumer node to be 1. For example:

<Consumer>

<Name value="Consumer_1"/>

<XmlTraceToStdout value="1"/>

</Consumer>

2. EMA configuration file (EmaConfig.xml)


consumerclient.txt (3.4 KiB)
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Hello @ashwathguru.s

Do you have a chance to test with ESDK 1.5.0 L1?