I am trying to implement a very simple PDX autoserialization in Geode. I've created a domain class of my own with a zero arg constructor:
public class TestPdx
{
public string Test1 { get; set; }
public string Test2 { get; set; }
public string Test3 { get; set; }
public TestPdx() { }
}
Now I want this class to auto serialize. I start a server cache with the following cache.xml where I attempt to register this type for auto PDX:
<?xml version="1.0" encoding="UTF-8"?>
<cache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://geode.apache.org/schema/cache"
xsi:schemaLocation="http://geode.apache.org/schema/cache
http://geode.apache.org/schema/cache/cache-1.0.xsd"
version="1.0">
<cache-server/>
<pdx>
<pdx-serializer>
<class-name>org.apache.geode.pdx.ReflectionBasedAutoSerializer</class-name>
<parameter name="classes"><string>TestPdx</string></parameter>
</pdx-serializer>
</pdx>
<region name="webclient" refid="REPLICATE_PERSISTENT"/>
</cache>
and then run the following code:
static void Main(string[] args)
{
// 1. cache
CacheFactory cacheFactory = CacheFactory.CreateCacheFactory();
Cache cache = cacheFactory
.SetSubscriptionEnabled(true)
.SetPdxReadSerialized(true)
.Create();
Serializable.RegisterPdxSerializer(new ReflectionBasedAutoSerializer());
RegionFactory regionFactory = cache.CreateRegionFactory(RegionShortcut.CACHING_PROXY);
IRegion<string, TestPdx> region = regionFactory.Create<string, TestPdx>("webclient");
// 3. TestPx object
TestPdx t = new TestPdx();
t.Test1 = "test1";
t.Test2 = "test2";
t.Test3 = "test3";
region["1"] = t;
// 4. Get the entries
TestPdx result1 = region["1"];
// 5. Print result
Console.WriteLine(result1.Test1);
Console.WriteLine(result1.Test2);
Console.WriteLine(result1.Test3);
}
This code is crashing at line region["1"] = t;
with error
GFCLI_EXCEPTION:System.Runtime.InteropServices.SEHException (0x80004005): External component has thrown an exception.
at apache.geode.client.SerializationRegistry.GetPDXIdForType(SByte* , SharedPtr<apache::geode::client::Serializable>* )
So I haven't registered the PDX type properly. How do you do that with native client?
THANKS