This topic provides an overview of the Spring Data for VMware Tanzu GemFire annotations to get started quickly.
All annotations provide additional configuration attributes along with associated properties to conveniently customize the configuration and behavior of GemFire at runtime. However, in general, none of the attributes or associated properties are required to use a particular GemFire feature. Declare the annotation to enable the feature and you are done. Refer to the individual Javadoc of each annotation for more details.
Configure a ClientCache
Application
To configure and bootstrap a GemFire ClientCache
application, use the following:
See @ClientCacheApplication Javadoc.
For more information, see Configuring GemFire Applications with Spring in Configuring a GemFire Client with the Spring Framework Using Annotations.
Configure Logging
To configure or adjust GemFire logging, annotate your Spring, GemFire client application class with @EnableLogging
, as follows:
Default log-level
is config. This annotation does not adjust log levels in your application and is only used for GemFire.
For more information, see Configuring Logging Configuring a GemFire Client with the Spring Framework Using Annotations.
Configure Statistics
To gather GemFire statistics at runtime, annotate your Spring, GemFire client application class with @EnableStatistics
, as follows:
See @EnableStatistics Javadoc.
For more information, see Configuring Statistics Configuring a GemFire Client with the Spring Framework Using Annotations.
Configure PDX
To enable GemFire PDX serialization, annotate your Spring, GemFire client application class with @EnablePdx
, as follows:
GemFire PDX Serialization is an alternative to Java Serialization with many added benefits. For one, it makes short work of making all of your application domain model types serializable without having to implement java.io.Serializable
.
By default, Spring Data for Tanzu GemFire configures the MappingPdxSerializer
to serialize your application domain model types, which does not require any special configuration out-of-the-box to properly identify application domain objects that need to be serialized and then perform the serialization since the logic in MappingPdxSerializer
is based on Spring Data’s mapping infrastructure. For more details, see MappingPdxSerializer in POJO Mapping.
See @EnablePdx Javadoc.
For more information, see Configuring PDX in Configuring a GemFire Client with the Spring Framework Using Annotations.
Configure SSL
To enable GemFire SSL, annotate your Spring, GemFire client application class with @EnableSsl
, as follows:
Minimally, GemFire requires you to specify a keystore and truststore using the appropriate configuration attributes or properties. Both keystore and truststore configuration attributes or properties may refer to the same KeyStore
file. Additionally, you must specify a username and password to access the KeyStore
file if the file has been secured.
GemFire SSL allows you to configure the specific components of the system that require TLS, such as client/server, Locators, Gateways, etc. Optionally, you can specify that all components of GemFire use SSL with ALL
.
See @EnableSsl Javadoc.
For more information, see Configuring SSL in Configuring a GemFire Client with the Spring Framework Using Annotations.
Configure Security
To enable GemFire security, annotate your Spring, GemFire client application class with @EnableSecurity
, as follows:
You must configure a username and password. For more details, see Configuring Client Security in Configuring a GemFire Client with the Spring Framework Using Annotations.
For more information, see Configuring Security in Configuring a GemFire Client with the Spring Framework Using Annotations.
Configure GemFire Properties
To configure other low-level GemFire properties not covered by the feature-oriented, Spring Data for Tanzu GemFire configuration annotations, annotate your Spring, GemFire client application class with @GemFireProperties
, as follows:
For the appropriate use of each property, see gemfire.properties vars.and gfsecurity.properties: GemFire Properties in the GemFire product documentation.
See @EnableGemFireProperties Javadoc.
For more information, see Configuring GemFire Properties in Configuring a GemFire Client with the Spring Framework Using Annotations.
Configure Caching
To use GemFire as a caching provider in Spring’s Cache Abstraction and have Spring Data for Tanzu GemFire automatically create GemFire Regions for the caches required by your application service components, annotate your Spring, GemFire client, application class with @EnableGemfireCaching
and @EnableCachingDefinedRegions
as follows:
Then define the application services that require caching as follows:
@EnableCachingDefinedRegions
is optional. You can manually define your Regions instead.
See @EnableCachingDefinedRegions Javadoc.
See @EnableGemfireCaching Javadoc.
For more information, see Configuring Spring’s Cache Abstraction in Configuring a GemFire Client with the Spring Framework Using Annotations.
Configure Regions, Repositories, and Entities for Persistent Applications
To quickly create Spring, GemFire persistent client, applications, annotate your application class wit @EnableEntityDefinedRegions
and @EnableGemfireRepositories
, as follows:
Next, define your entity class and use the @Region
mapping annotation to specify the Region in which your entity will be stored, as follows:
Note: The
@Region("Books")
entity class annotation is used by the@EnableEntityDefinedRegions
to determine the Regions required by the application.
Finally, define your CRUD Repository with simple queries to persist and access Books
, as follows:
For more information, see Spring Data for Tanzu GemFire Repositories.
Configure Client Regions from Cluster-defined Regions
Alternatively, you can define client PROXY Regions from Regions already defined in the cluster using @EnableClusterDefinedRegions
, as follows:
For more information, see Configured Cluster-Defined Regions in Configuring a GemFire Client with the Spring Framework Using Annotations.
Configure Functions
GemFire Functions are useful in distributed compute scenarios where a potentially expensive computation requiring data can be performed in parallel across the nodes in the cluster. In this case, it is more efficient to bring the logic to where the data is located (stored) rather than requesting and fetching the data to be processed by the computation.
Use the @EnableGemfireFunctionExecutions
along with one of the Function calling annotations: @OnMember
, @OnMembers
, @OnRegion
, @OnServer
and @OnServers
.
Configure Continuous Query
Real-time, event stream processing is becoming an increasingly important task for data-intensive applications, primarily to respond to user requests in a timely manner. GemFire Continuous Query (CQ) will help you achieve this rather complex task quite easily.
Enable CQ by annotating your application class with @EnableContinuousQueries
and define your CQs along with the associated event handlers, as follows:
Then, define your CQs by annotating the associated handler method with @ContinousQuery
, as follows:
Anytime an event occurs changing the Customer
data to match the predicate in your continuous OQL query (CQ), the process
method will be called.
A new feature in GemFire 10.1 is the ability to exclude certain kinds of events from triggering your CQs. You can use this feature by setting the excludedEvents
attribute on the @ContinuousQuery
annotation.
The above example excludes DESTROY and INVALIDATE events, so the CQ will only trigger on CREATE or UPDATE events.
Content feedback and comments