0

Is it possible to do Javaconfig i.e annotations in spring instead of xml to create client regions in Spring gemfire?

I need to plug in cache loader and cache writer also to the regions created...how is that possible to do?

I want to perform the client pool configuration as well..How is that possible?

Arghya Sadhu
  • 41,002
  • 9
  • 78
  • 107

2 Answers2

1

There is a good example of this in the spring.io guides. However, GemFire APIs are factories, wrapped by Spring FactoryBeans in Spring Data Gemfire, so I find XML actually more straightforward for configuring Cache and Regions.

dturanski
  • 1,723
  • 1
  • 13
  • 8
1

Regarding... "how can I create a client region in a distributed environment?"

In the same way the Spring IO guides demonstrate Regions defined in a peer cache on a GemFire Server, something similar to...

@Bean
public ClientRegionFactoryBean<Long, Customer> clientRegion(ClientCache clientCache) {
    return new ClientRegionFactoryBean() {
        {
            setCache(clientCache);
            setName("Customers");
            setShortcut(ClientRegionShortcut.CACHING_PROXY);  // Or just PROXY if the client is not required to store data, or perhaps another shortcut type.
            ...
        }
    }
} 

Disclaimer, I did not test this code snippet, so it may need minor tweaking along with additional configuration as necessary by the application.

You of course, will defined a along with a Pool in your Spring config, or use the element abstraction on the client-side.

John Blum
  • 7,381
  • 1
  • 20
  • 30