This topic discusses function implementation and execution in Spring Boot for VMware GemFire, and using VMware GemFire in a Spring context for distributed computing use cases.


Distributed computing, particularly in conjunction with data access and mutation operations, is a very effective and efficient use of clustered computing resources. This is similar to MapReduce.

A naively conceived query returning potentially hundreds of thousands (or even millions) of rows of data in a result set to the application that queried and requested the data can be very costly, especially under load. Therefore, it is typically more efficient to move the processing and computations on the predicated data set to where the data resides, perform the required computations, summarize the results, and then send the reduced data set back to the client.

Additionally, when the computations are handled in parallel, across the cluster of computing resources, the operation can be performed much more quickly. This typically involves intelligently organizing the data using various partitioning, or sharding, strategies to uniformly balance the data set across the cluster.

VMware GemFire addresses this very important application concern in its Function execution framework.

Spring Data for VMware GemFire builds on this function execution framework by letting developers implment and execute VMware GemFire functions with a simple POJO-based annotation configuration model.

Taking this a step further, Spring Boot for VMware GemFire auto-configures and enables both function implementation and execution out-of-the-box. Therefore, you can immediately begin writing functions and invoking them without having to worry about all the necessary plumbing to begin with. You can rest assured that it works as expected.

Applying Functions

Earlier, when we talked about caching, we described a FinancialLoanApplicationService class that could process eligibility when someone (represented by a Person object) applied for a financial loan.

This can be a very resource intensive and expensive operation, since it might involve collecting credit and employment history, gathering information on outstanding loans, and so on. We applied caching in order to not have to recompute or redetermine eligibility every time a loan office may want to review the decision with the customer.

But, what about the process of computing eligibility in the first place?

Currently, the application’s FinancialLoanApplicationService class seems to be designed to fetch the data and perform the eligibility determination in place. However, it might be far better to distribute the processing and even determine eligibility for a larger group of people all at once, especially when multiple, related people are involved in a single decision, as is typically the case.

We can implement an EligibilityDeterminationFunction class by using Spring Data for VMware GemFire:

Example 1. Function implementation

class EligibilityDeterminationFunction {

    @GemfireFunction(HA = true, hasResult = true, optimizeForWrite=true)
    public EligibilityDecision determineEligibility(FunctionContext functionContext, Person person, Timespan timespan) {
        // ...

By using the Spring Data for VMware GemFire @GemfireFunction annotation, we can implement our Function as a POJO method. Spring Data for VMware GemFire appropriately handles registering this POJO method as a proper Function with VMware GemFire.

If we now want to call this function from our Spring Boot ClientCache application, we can define a function execution interface with a method name that matches the function name and that targets the execution on the EligibilityDecisions Region:

Example 2. Function execution

interface EligibilityDeterminationExecution {

  EligibilityDecision determineEligibility(Person person, Timespan timespan);


We can then inject an instance of the EligibilityDeterminationExecution interface into our FinancialLoanApplicationService, as we would any other object or Spring bean:

Example 3. Function use

class FinancialLoanApplicationService {

    private EligibilityDeterminationExecution execution;

    public FinancialLoanApplicationService(EligibilityDeterminationExecution execution) {
        this.execution = execution;

    public EligibilityDecision processEligibility(Person person, Timespan timespan) {
        return this.execution.determineEligibility(person, timespan);

As with caching, no additional configuration is required to enable and find your application Function implementations and executions. You can simply build and run. Spring Boot for VMware GemFire handles the rest.

Tip It is common to "implement" and register your application Functions on the server and "execute" them from the client.
check-circle-line exclamation-circle-line close-line
Scroll to top icon