Announcement Announcement Module
No announcement yet.
client region json serialization not working Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • client region json serialization not working


    I am trying to get JSON serialization working in a client-server environment.

    The example is working fine on my PC. But it's using a local cache/region. Once I replace that with a client-cache and a client region, it stops working.

    My cache server setting:

    <gfe:cache-server id="spgCacheServer" port="24165" groups="spgCacheServerGroup"/>
        <util:properties id="gemfireProperties">
            <prop key="mcast-port">0</prop>
            <prop key="start-locator">localhost[9999]</prop>
        <gfe:cache close="true" lazy-init="false" properties-ref="gemfireProperties">  <!-- use default "gemfireCache" as the id -->
            <gfe:dynamic-region-factory/> <!-- dynamically create subregions -->
        <gfe:partitioned-region id="tradeRegion" copies="2" total-buckets="4">
                <bean class="org.mytest.cache.gemfire.test.server.LoggingCacheListener"/>
        <context:property-placeholder location=""/>
    The file contains only license.

    My client setting:
        <aop:aspectj-autoproxy />
        <gfe-data:datasource subscription-enabled="true">
            <gfe-data:locator host="localhost" port="9999"/>
        <gfe-data:json-region-autoproxy pretty-print="true" convert-returned-collections="false" />
        <gfe:transaction-manager/> <!-- copy on read is enabled -->
        <gfe:client-cache />
        <gfe:client-region id="tradeRegion" shortcut="CACHING_PROXY_HEAP_LRU">
                <bean class="org.mytest.cache.gemfire.test.server.LoggingCacheListener"/>
            <!-- This is to make sure we get updates from the server to keep data consistent -->
            <!-- receive-values=false means we get invalidation events, not changed values. -->
            <!-- true means we want to get values -->
            <gfe:key-interest durable="false" result-policy="NONE" receive-values="true">
                <bean class="java.lang.String">
                    <constructor-arg value="ALL_KEYS" />
            <gfe:eviction type="MEMORY_SIZE" threshold="2" action="LOCAL_DESTROY"/> <!-- size in MB -->
        <!--<gfe:local-region id="tradeRegion">-->
            <!--<gfe:cache-listener ref="listener"/>-->
        <!--<bean id="listener" class="org.mytest.cache.gemfire.test.server.LoggingCacheListener"/>-->
        <bean id="tradeTemplate" class="">
            <property name="region" ref="tradeRegion"/>
        <bean id="client" class="org.mytest.cache.gemfire.test1.client.TemplateCacheClient">
            <property name="template" ref="tradeTemplate"/>
    The cache contains only objects, not JSON strings.

    Could you please take a look what I am missing?

    Appreciate it.

    P.S., I googled everything related to client-cache, but couldn't find any clue.

  • #2
    Hi Rick,

    Sorry for the late response to your issue storing JSON in Client Cache Regions. I wrote a little example test app to play around with the configuration and found that the SDG JSON support does not work with the SDG datasource bean definition for defining the client-cache/pool. I am not sure why this is yet, but I kept getting a on my domain class.

    If you change your datasource bean definition...

    <gfe-data:datasource subscription-enabled="true">
        <gfe-data:locator host="localhost" port="9999"/>

    <gfe:pool id="locatorConnectionPool" subscription-enabled="true">
        <gfe:locator host="localhost" port="9999"/>
    <gfe:client-cache pool-name="locatorConnectionPool"/>
    You should be golden.

    I have attached my example test code for your reference. There are a few differences...

    1. I did not doing anything with subscriptions and interests.
    2. My Client (local) Region is a PROXY, not a CACHING_PROXY (but, should not matter).
    3. I setup my Server to embed a Locator and be Manager so that you can connect with Gfsh.
    4. what else...

    Have a look. Hope this helps.



    • #3
      Hmm, does not like my ZIP file attachment; seems to want to "render" it, argh.