Announcement Announcement Module
Collapse
No announcement yet.
Minimal Spring based Gemfire Client application Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Minimal Spring based Gemfire Client application

    Hi,

    I'm trying to setup a minial Gemfire client application. On the command line, I started

    a) a Gemfire locator: gemfire start-locator -server=true -port=41111

    b) a Gemfire cache server: cacheserver start -J-Xmx8000m locators=127.0.0.1:41111 cache-xml-file=../defaultConfigs/cache.xml

    with cache.xml looking like this:

    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE cache PUBLIC "-//GemStone Systems, Inc.//GemFire Declarative Cache 6.5//EN" "http://www.gemstone.com/dtd/cache6_5.dtd">
    <cache lock-lease="120" lock-timeout="60" search-timeout="300" is-server="false" copy-on-read="false">
    	<cache-server port="40404" />
    	<region name="Customers">
    		<region-attributes data-policy="replicate" scope="distributed-ack">
    		</region-attributes>
    	</region>
    </cache>
    Both Java processes are up and running and listening on the TCP ports 40404 and 41111.

    From my understanding of http://static.springsource.org/sprin...otstrap:region , a pure client only needs a (pooled) Gemfire locator and a region definition. On the client side, my Spring app context looks like this

    Code:
    <?xml version="1.0"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
    	xmlns:gfe="http://www.springframework.org/schema/gemfire" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
    		http://www.springframework.org/schema/gemfire http://www.springframework.org/schema/gemfire/spring-gemfire.xsd">
    
    	<!-- pool declaration -->
    	<gfe:pool id="gemfire-pool">
    		<gfe:locator host="127.0.0.1" port="41111" />
    	</gfe:pool>
    
    	<!--  Region -->
    	<gfe:client-region id="someRegion" pool-name="gemfire-pool" />
    
    	<bean id="template" class="org.springframework.data.gemfire.GemfireTemplate">
    		<property name="region-ref" ref="someRegion" />
    	</bean>
    </beans>
    When I start the application, the following exception is thrown:

    Code:
    Caused by: java.lang.IllegalStateException: Distributed System must be created before creating pool
    	at com.gemstone.gemfire.cache.client.internal.PoolImpl.<init>(PoolImpl.java:172)
    	at com.gemstone.gemfire.cache.client.internal.PoolImpl.create(PoolImpl.java:114)
    	at com.gemstone.gemfire.internal.cache.PoolFactoryImpl.create(PoolFactoryImpl.java:382)
    	at org.springframework.data.gemfire.client.PoolFactoryBean.afterPropertiesSet(PoolFactoryBean.java:148)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1469)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1409)
    	... 37 more
    I don't want to start an embedded distributed system at all, I want to connect to the already running one.

    Any hints?

    TIA,
    Tobias

  • #2
    The DS (Distributed System) needs to be created at all times even for client - note that the DS per se acts as a (lightweight) registry rather then an actual grid. Based on your config, the grid starts to be initialized but whatever you choose, you need the DS.

    P.S. As you can see the error is thrown from within the Gemfire code. For Gemfire specific questions, I strongly recommend the GemFire forums - while I'd like all questions to be answered here, this forum is mainly targeted towards the Spring integration only rather then Gemfire as an entire product.

    Comment


    • #3
      In case I wasn't clear, try adding a simple <cache /> to your configuration and rerun your example.

      Comment


      • #4
        Hi Costin,
        What is the means of setting the EntryTimeToLive on the client region in the configuration file. Nothing in the schema http://www.springframework.org/schem...ng-gemfire.xsd provides that option.

        Any directions please.

        Thanks
        Kiran

        Comment


        • #5
          A client region is your client side cache, and Gemfire allows you fine grained control on how much you want client side. So an app like a trading app, may only want to keep cache data around for a few minutes, while a logistics app may want to keep data around for a few days until an order is processed.

          Comment

          Working...
          X