Tanzu GemFire on Cloud Foundry 2.1

An Example Java App

Last Updated March 03, 2025

This topic presents an example Java app to use with VMware Tanzu GemFire on Cloud Foundry.

The sample Java client app at https://github.com/cf-gemfire-org/cloudcache-sample-app.git demonstrates how to connect an app to a service instance.

These instructions assume:

  • A Tanzu GemFire on Cloud Foundry service instance is running.
  • You have Cloud Foundry credentials for accessing the Tanzu GemFire on Cloud Foundry service instance.
  • You have a service key for the Tanzu GemFire on Cloud Foundry service instance.
  • You have a login on the Pivotal Commercial Maven Repository at https://commercial-repo.pivotal.io.
  • You have a gfsh client of the same version as is used within your Tanzu GemFire on Cloud Foundry service instance.

Follow these instructions to run the app.

  1. Clone the sample Java app from https://github.com/cf-gemfire-org/cloudcache-sample-app.git.
  2. Update your clone of the sample Java app to work with your Tanzu GemFire on Cloud Foundry service instance:
    • Modify the manifest in manifest.yml by replacing service0 with the name of your Tanzu GemFire on Cloud Foundry service instance.
    • Replace the username and password in the gradle.properties file with your username and password for the Pivotal Commercial Maven Repository.
    • Update the Tanzu GemFire version in the dependencies section of the build.gradle file to be the same as the version within your Tanzu GemFire on Cloud Foundry service instance.
  3. Build the app with

    $ ./gradlew clean build
    
  4. In a second shell, run gfsh.
  5. Use gfsh to connect to the Tanzu GemFire on Cloud Foundry service instance as described in Connect with gfsh over HTTPS.
  6. Use gfsh to create a region named test as described in Create Regions. This sample app places a single entry into the region, so the region type is not important. PARTITION_REDUNDANT is the recommended choice.
  7. In the shell where the app was built, deploy and run the app with

    cf push -f manifest.yml
    
  8. After the app starts, there will be an entry of (“1”, “one”) in the test region. you can see that there is one entry in the region with the gfsh command:

    gfsh>describe region --name=test
    

    For this very small region, you can print the contents of the entire region with a gfsh query:

    gfsh>query --query='SELECT * FROM /test'