Spring Boot for GemFire Basics
This guide walks you through setting up your local development environment using VMware GemFire and a Hello, World! client application.
What is VMware GemFire?
VMware GemFire is an enterprise-grade, high-speed, in-memory data and compute grid that serves a variety of use cases. From high-performance, low-latency applications where data must be processed with sub-millisecond delivery times, to caching and key-value stores, GemFire shines as an ultra-fast system of record.
In all GemFire use cases, data remains consistent, secure, and up to date. GemFire can be deployed and replicated across multiple data centers with unlimited scale and extremely fast performance. Plus, it can be deployed on-premises, in the public cloud, in virtual machines, containers, or even orchestrated via Kubernetes.
GemFire is used by customers in many real-world applications (e.g., banking, billing, insurance, inventory, logistics, etc.) to replace NoSQL databases, achieve massive parallel processing at incredibly fast speeds, and supercharge intelligent, modern applications.
Starting VMware GemFire for Local Development
Download the .tgz file from the Broadcom Support Portal
Download VMware GemFire .tgz from the Broadcom Support Portal.
Unzip or expand the file.
Open a terminal and navigate to the GemFire folder that was unzipped in Step 2.
In the terminal, navigate to the
bin
folder.run the following command to start the GemFire SHell (GFSH)
./gfsh
You should see the GemFire Shell start with a version similar to the following image
Set Up Your Local Environment
This section will guide you through testing a Hello, World! client app on your local machine to confirm that your local environment is set up correctly.
What You’ll Need
-
The Hello, World! example.
-
JDK 8, 11, or 17. JDK 17 is required to use Spring Boot 3.0 or higher.. JDK 17 is required to use Spring Boot 3.0 or higher.
-
Spring Boot 2.7 or above
-
GemFire 9.15+
1. Download the Hello, World! Example
- Clone the Hello, World! app from the VMware GemFire examples repo.
$ git clone https://github.com/gemfire/spring-for-gemfire-examples.git
Update the
gradle.properties
file with your Broadcom Maven Repo username and password(token). For additional instructions, please review the Spring Boot for VMware GemFire Quick Start guide.
2. Start an VMware GemFire Cluster
Required
Make sure that you have downloaded and started VMware GemFire before proceeding.
The following steps will start a small local cluster for the Hello, World! app to connect
In a terminal start the GemFire Shell (gfsh) if it is not currently running
./gfsh
- Start a locator. Locators provide both discovery and load balancing services.
start locator --name=hello-world-locator
- Start a server. Servers are primarily used to store data in regions (similar to a table in a relational database.
start server --name=hello-world-server
- Once those commands have finished run the
list members
command
list members
Member Count : 2
Name | Id
------------------- | ---------------------------------------------------------------------------
hello-world-locator | 192.168.1.14(hello-world-locator:33323:locator)<ec><v0>:41000 [Coordinator]
hello-world-server | 192.168.1.14(hello-world-server:33423)<v1>:41001
3. Build and Run the App
Open a different terminal session, navigate to the working directory of spring-for-gemfire-examples/hello-world
, and build the application
./gradlew build
./gradlew bootRun
We are running a Gradle task so you will most likely see the executing progress bar stop around 75% when the app is up and running.
Now that the application has started, open a browser and go to (http://localhost:8080).
You should see something similar to the below, which represents an artificial time delay simulating a database query.
key: hello value: 2019-10-01T16:17:51.557 (this will be your current date & time) time to look up: 3057ms (quantity of time that it took to acquire the key-value pair).
key: hello
value: 2019-10-01T16:17:51.557 (this will be your current date & time)
time to look up: 6ms (quantity of time that it took to acquire the key-value pair).
Note that the time to look up has been significantly reduced. This represents the app getting the information from the cache (VMware GemFire), instead of querying the database.
To confirm that your app is connected to your local cluster, in your gfsh terminal run the following commands
- List the regions
list regions
List of regions
---------------
Hello
- Confirm the web page timestamp has the same value as that stored in your Hello region. Run the gfsh command
get --key hello --region=/Hello
Response from the gfsh command
Result : true
Key Class : java.lang.String
Key : hello
Value Class : java.lang.String
Value : "2020-12-08T13:46:47.322"
key: hellovalue: 2020-12-08T13:46:47.322
time to look up: 2ms
4. Stop the App and the VMware GemFire Cluster
-
Stop the *Hello, World! app.
-
Then shutdown the VMware GemFire cluster - this will stop the locator and server, and delete any data you may have in the cluster.
In your gfsh terminal run the following command
shutdown --include-locators=true
Exit gfsh by typing
exit
.
Learn More
Now that you have successfully set up your local development environment, check out some other guides
Set up your VMware GemFire service instance on the Tanzu Application Service.
Set up VMware GemFire for Kubernetes.
Create an application that utilizes Spring Boot for VMware GemFire and Spring Session for session state caching.