In EMA Java, is it possible to get and keep a copy of a FieldEntry ?
At the moment when i retrieve a message, i decode it and populate my own object.
My domain object has 2 hashtables, both indexed by the FieldID.
The first one contains the FieldEntry.load().toString(), while the second one contains the FieldEntry directly, in order to parse it later on depending on the type.
However, there are some issues when i retrieve multiple items successively, the map of FieldEntry always contain the fields of the last item requested.
Is it possible somehow to retain a copy of a FieldEntry for later use ?
It is by designed of the EMA API that it currently currently does not support cloning of the Data objects and it internally reuses the FieldEntry and RefreshMsg objects. This information has been described in the warning section of section 3.2.3 “Data Class” in the EMA Java Development guide document.
If the application just needs the content for the business logic use case, the application can store the FieldEntry’s content as string (like your value hashtable).Otherwise, the application can create the local FieldEntry object to cache data via the EmaFactory.createFieldEntry() function by setting each information from the incoming FieldEntry to the new local FieldEntry object.
Could you please share the code that initiate and keeps data into the Hashtable?
Do you have separate hashtable for each item or only hashtable for all items? Basically, if you put new value with the same key (FID) to the hashtable, it will update the current value to be the new one.
(Assuming similar behavior with EMA c++)
Every time you call .forth() on FieldList, private object (of type FieldEntry) within FieldList is being overwritten with a new value. And when you call .getEntry() -- reference to this internal object is returned.
So all your references to FieldEntries that you stored will be pointing to same internal object. That means you should manually clone state of FieldEntry and put it in your hashtable, because otherwise this FieldEntry will be overwritten after next .forth() call.
Hi @GAUTHIER.ROEBROECK I modified EMA example based on your application logic as following steps:
I found that sometime, the hashtable's FieldEntry returns FID and data of the recent another item incoming data, not the it's refresh data. The values hashtable (string) does not encounter the same problem.
----- EUR= got update ----- onUpdateMsg: Item Name: EUR= incoming data Fid: 114 Name = BID_NET_CH DataType: Real Value: 0.0027 incoming data Fid: 372 Name = IRGPRC DataType: Real Value: 0.25 ----- VOD.L got update ----- onUpdateMsg: Item Name: VOD.L ----- Print out VOD.L refresh that should has only 22 and 25 FIDs ----- The Refresh message is Data for: = VOD.L Fid: 372 Name = IRGPRC DataType: Real 0.25 Fid: 114 Name = BID_NET_CH DataType: Real 0.0027 ----- VOD.L hashtable's FieldEntry shows recently EUR= FIDs instead -----
Is it the similar behavior as your problem?
did you manage to achieve your aim? If so, could you please explain your approach?
I have the very same requirement: caching the payload of an OMM (MarketPrice) update for later use, but I can't find any clear way to copy a FieldEntry instance using directly EMA (C++).
@GAUTHIER.ROEBROECK, @Wasin Waeosri, in case a custom solution is needed, could please share any recommendations, best practices or snippets to do it in the right way?
It would be very much appreciated.