2017-08-08 6 views
1

Geode REST APIが自動的にPdxInstanceタイプに変換するJsonデータでGeode領域にデータを取り込むRESTクライアントがあります。私は、次のコードはで得ることができることをhereから見てきたGeodeネイティブクライアントdeserialise PdxInstanceImpl

PDX[7534066,__GEMFIRE_JSON]{@type=MyClass, Field1=Value1, Field2=Value2}

領域がTValタイプev.NewValueがタイプPdxInstanceImplとして見てのように見えるされているC#のネイティブクライアントのリスナーAfterCreate(EntryEvent<TKey, TVal> ev)をトリガー個々のPdxフィールド

IPdxInstance pdx = (IPdxInstance)ev.NewValue; 
pdx.GetField("Field1"); 

これはフィールドレベルで動作しますが、PdxInstanceImplPdxInstanceに届くので、別の地域に直接入れることができます。あるいは、すべてのフィールドを1つのJson(文字列として)に戻してJsonの文字列を別の地域に入れるか、好きなように使用します。

だから、明らかMyClassPdxInstanceをautoserializeする方法があるが、私は

MyClass c = (MyClass)pdx;

を試みるならば、私はいくつかのJava client examplesから見てきたSystem.InvalidCastException: Unable to cast object of type 'Apache.Geode.Client.Internal.PdxInstanceImpl' to type 'MyClass'

は、あなたがするタイプPdxInstanceImplを使用することができます取得しますデータを取得して、C#ネイティブクライアントでエラーが発生する:PdxInstanceImpl is inaccessible due to its protection level

私はautoserializerを追加しました。結果は同じです。

私はここで何が不足していると思いますか?最後に感謝

+0

pdx.GetObject()を引き起こす '{System.NullReferenceException:オブジェクトのインスタンスに設定されていないオブジェクト参照を。 Apache.Geode.ClientでApache.Geode.Client.PdxWrapper.FromDataでApache.Geode.Client.ReflectionBasedAutoSerializer.deserializeFieldsでSystem.Object.GetType() (文字列O、IPdxReaderリーダ) (IPdxReaderリーダ) で。 Internal.PdxHelper.DeserializePdx(DataInput dataInput、Boolean forceDeserialize、Int32 typeId、Int32 length) at Apache.Geode.Client.Internal.PdxInstanceImpl.GetObject()} ' – rupweb

答えて

0

はIフィールドアプローチによってフィールドを使用した:

IPdxInstance pdx = (IPdxInstance)ev.NewValue; pdx.GetField("Field1"); pdx.GetField("Field2"); pdx.GetField("Field3"); etc...

関連する問題