1

We have a Spring Mvc application (client) where it connect to two different Gemfire distributed system and exposed data through REST services; While bootstrapping Spring Mvc application we are getting an exception that it cannot connect to two distributed systems;We have defined two client cache in our configuration which is causing an issue but we have requirement to connect to two distributed system. How we can resolve this error ? We have defined two client cache tag in the servlet xml which is causing an issue;

Ameer Khan
  • 11
  • 3

1 Answers1

0

Essentially, both the GemFire DistributedSystem and the ClientCache are Singletons in a single JVM process and it is not possible to have 2 distinct client caches in the same JVM with significantly different DistributedSystem configurations.

I have heard of customers using a single client cache connected to 2 different GemFire clusters (i.e. DistributedSystems), although I am not sure this is actually recommended.

You might try the following. Say you have two clusters...

Cluster 1: Locator A, Server B, Server C

Cluster 2: Locator Z, Server X, Server Y.

You then might be able to create a single cache with 2 pools like so...

<gfe:client-cache/>

<gfe:pool id="clusterOnePool" ... >
  <gfe:locator host="LocatorA-Host/IP" port="LocatorA-Port"/>
</gfe:pool>

<gfe:pool id="clusterTwoPool" ...>
  <gfe:locator host="LocatorZ-Host/IP" port="LocatorZ-Port"/>
</gfe:pool>

<gfe:client-region id="RegionInClusterOne" shortcut="[PROXY|CACHING_PROXY]"
                   pool-name="clusterOnePool">
  ...
</gfe:client-region>

<gfe:client-region id="RegionInClusterTwo" shortcut="[PROXY|CACHING_PROXY]"
                   pool-name="clusterTwoPool">
  ...
</gfe:client-region>

I am not sure if this works, but maybe. Also, I am not sure that is actually recommended either.

What is your UC for having clients connect to 2 different clusters?

John Blum
  • 7,381
  • 1
  • 20
  • 30
  • Note, I created an example of this working here (https://github.com/jxblum/spring-gemfire-tests/blob/master/src/test/java/org/spring/data/gemfire/cache/ClientCacheConnectedToMultipleDistributedSystemsTest.java) You need to first setup run configurations in your IDE for the 2 GemFire Server configurations (GemFireServerAppOne and GemFireServerAppTwo). Once the servers are running, then you can run the test. Also note, in no way are the 2 servers participating in the same DS. They are separate and even though they are standalone, they really do represent 2 clusters (with 1 member each). – John Blum Mar 22 '16 at 21:55
  • Hi John , when I tried the above configuration i got an error NoUniquieBeanDefinitionException : No qualifying bean of type com.gemstone.gemfire.cache.client.Pool – Ameer Khan Mar 23 '16 at 09:27
  • Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'gemfireCache': FactoryBean threw exception on object creation; n ested exception is org.springframework.beans.factory.BeanInitializationException: No bean of type 'com.gemstone.gemfire.cache.client.Pool' having name 'null' was found.; nested exception is org.springframework.beans.factory.NoUniqueBeanDefinitionException: No qualifying bean of type [com.gemstone.gemfire.cache.client.Poo l] is defined: expected single matching bean but found 2: – Ameer Khan Mar 23 '16 at 09:33
  • Yeah, I heard through the "grapevine" that you were using SDG 1.7.0, ;-). You should upgrade to the latest maintenance release, 1.7.4, which only includes bug fixes and minor enhancements (if any). I was able to get this to work with 1.7.0, but I had to add a few additional @Qualifiers along with removing the "explicit" pool name using the poolName property. 1.7.4 works OOTB without any additional work. Check with Shuvro for further details. – John Blum Mar 30 '16 at 14:45
  • I think it is not related to SDG version, it is more related to gemfire version. When we were on Gemfire 6.5 version , we bootstrap spring web application (client) using the but the same is not working on 8.2 Gemfire version. – Ameer Khan Mar 31 '16 at 19:57
  • In 8.2 we are trying something like this: and we are getting the error..beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [com.gemstone.gemfire.cache.client.Pool] is defined – Ameer Khan Mar 31 '16 at 19:58
  • Why I'm not able to bootstrap spring web application by explicitly reading cache-xml-file in Gemfire 8.2 version? I tried both client-cache and cache gfe tag but no luck. :-( – Ameer Khan Mar 31 '16 at 20:32