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: ")
Best Answer
-
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.
0
Answers
-
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)
0 -
Are you using Consumer.scala sample without any modifications?
@Pimchaya.Wongrukun can you please help with this code snippet.
0 -
Hello @ashwathguru.s
You can see an example of EMA Consumer in the Scala language from this article.
0 -
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:
- 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)
0 -
Hello @ashwathguru.s
Do you have a chance to test with ESDK 1.5.0 L1?
0
Categories
- All Categories
- 6 AHS
- 39 Alpha
- 161 App Studio
- 4 Block Chain
- 4 Bot Platform
- 16 Connected Risk APIs
- 47 Data Fusion
- 30 Data Model Discovery
- 608 Datastream
- 1.3K DSS
- 577 Eikon COM
- 4.9K Eikon Data APIs
- 7 Electronic Trading
- Generic FIX
- 7 Local Bank Node API
- Trading API
- 2.7K Elektron
- 1.3K EMA
- 236 ETA
- 519 WebSocket API
- 33 FX Venues
- 10 FX Market Data
- 1 FX Post Trade
- 1 FX Trading - Matching
- 12 FX Trading – RFQ Maker
- 5 Intelligent Tagging
- 2 Legal One
- 20 Messenger Bot
- 2 Messenger Side by Side
- 9 ONESOURCE
- 7 Indirect Tax
- 59 Open Calais
- 264 Open PermID
- 39 Entity Search
- 2 Org ID
- PAM
- PAM - Logging
- 8.4K Private Comments
- 6 Product Insight
- Project Tracking
- ProView
- ProView Internal
- 20 RDMS
- 1.4K Refinitiv Data Platform
- 367 Refinitiv Data Platform Libraries
- 3 Refinitiv Due Diligence
- LSEG Due Diligence Portal API
- 3 Refinitiv Due Dilligence Centre
- Rose's Space
- 1.1K Screening
- 18 Qual-ID API
- 13 Screening Deployed
- 23 Screening Online
- 10 World-Check Customer Risk Screener
- 990 World-Check One
- 44 World-Check One Zero Footprint
- 45 Side by Side Integration API
- Test Space
- 3 Thomson One Smart
- 1.2K TR Internal
- Global Hackathon 2015
- 2 Specialists Who Code
- 10 TR Knowledge Graph
- 150 Transactions
- 142 REDI API
- 1.7K TREP APIs
- 4 CAT
- 21 DACS Station
- 117 Open DACS
- 1.1K RFA
- 103 UPA
- 172 TREP Infrastructure
- 224 TRKD
- 886 TRTH
- 5 Velocity Analytics
- 5 Wealth Management Web Services
- 60 Workspace SDK
- 9 Element Framework
- 5 Grid
- 13 World-Check Data File
- Yield Book Analytics
- 46 中文论坛