I am working on a FIX repeating group where a quote request can have x legs. I have made a Leg class like this:
public class Leg : IPdxSerializable
{
public string Side { get; set; }
public decimal Size { get; set; }
public string ValueDate { get; set; }
public void ToData(IPdxWriter writer)
{
writer.WriteString("Side", Side);
writer.WriteDouble("Size", Convert.ToDouble(Size));
writer.WriteString("ValueDate", ValueDate);
}
public void FromData(IPdxReader reader)
{
Side = reader.readString("Side");
Size = (decimal) reader.ReadDouble("Size");
ValueDate = reader.readString("ValueDate");
}
public static IPdxSerializable CreateDeserializable()
{
return new Leg();
}
public Leg () { }
}
The legs for a quote request are written as an array of these Leg
objects. In the quote request class there is a Leg[]
declaration and ToData FromData
implementation. The quote request object is built and put
into a Geode region as a PDX Type, in which the array of legs is written by the PDX Writer as:
writer.WriteObjectArray("Legs", Legs.ToList<object>());
I have tried different types for the List
of Leg
as both PDX type and domain object type, but when I get
the object in GFSH
the leg array has given flavours of errors like:
Could not create an instance of a class Leg (through reference chain: org.apache.geode.pdx.internal.PdxInstanceImpl[0]->org.apache.geode.pdx.internal.PdxInstanceImpl["object"])
or
Could not create an instance of a class Leg (through reference chain: java.util.Vector[0]->org.apache.geode.pdx.internal.PdxInstanceImpl["object"])
I thought this was because the Geode server has not had a Leg
object type registered in the server's TypeRegistry
. Since Geode version 10 of the native client there is no longer a Serializable.RegisterPdxType
which was used like this:
Serializable.RegisterPdxType(Leg.CreateDeserializable);
I have found the TypeRegistry class reference and on initializing the cache and regions also register the type into the cache:
_cache.TypeRegistry.RegisterPdxType(Leg.CreateDeserializable);
but still get the same error.
It's the same error if an array of Legs is written merely as an object
writer.WriteObject("Legs", Legs);
If I convert the Leg
object into a string[]
representation this is working fine with either WriteStringArray
and ReadStringArray
as a quote request where the Legs
are an array of strings, but that has it's own problems, I want to use an array of Leg objects, preferably PDX wrapped. What am I missing?
rupweb you can just use:
and
instead of WriteObjectArray/ReadObjectArray. Not sure what the limitations are on these. Still investigating.