This module provides a java.util.function.Supplier
that can be reused and composed in other applications.
The Supplier
configures an VMware GemFire client that connects to an external VMware GemFire cache server or locator to monitor an existing region.
If gemfire.supplier.query
is provided, the supplier will create a continuous query on the region and publish any events that meet the select criteria.
If no query is provided, the supplier will publish all create and update events on the region.
If a query is provided, the supplier uses the ContinuousQueryMessageProducer
from Spring Integration
which wraps a ContinuousQueryListenerContainer
and emits a reactive stream of objects, extracted from a VMware GemFire CqEvent, which holds all of the event details.
A SpEl Expression, given by the property gemfire.cq.supplier.event-expression
is used to extract desired fields from the CQEvent payload.
The default expression is newValue
which returns the current value from the configured Region.
If no query is provided, the supplier uses the CacheListeningMessageProducer
from Spring Integration
which wraps a CacheListener
and emits a reactive stream of objects, extracted from a VMware GemFire EntryEvent, which holds all of the
event details.
A SpEl Expression, given by the property gemfire.supplier.entry-event-expression
is used to extract desired fields from the EntryEvent payload.
The default expression is newValue
which returns the current value from the configured Region.
NOTE: Retrieving the value by itself is not always sufficient, especially if it does not contain the key value, or any additional context.
The key is referenced by the field key
.
If the cached key and value types are primitives, a simple expression like key + ':' +newValue
may be useful.
To access the entire EntryEvent, set the expression to #root
or #this
.
The configured MessageProducer emits objects to the supplier implemented as Supplier<Flux<?>>
.
Users have to subscribe to the returned Flux
to receive the data.
The supplier works with PDX serialized cache objects of type PdxInstance, which VMware GemFire uses to store objects that can be represented as JSON.
If the target region uses PDX serialization and you set gemfire.client.pdx-read-serialized
to true
, PdxInstance objects will be returned as JSON strings.
You can import the GemFireSupplierConfiguration
configuration in a Spring Boot application and then inject the gemfireSupplier
bean as type Supplier<Flux<T>>
, where T
is the expected return type.
If necessary, can use the bean name gemfireSupplier
as a qualifier.
Once injected, you can invoke the get
method of the Supplier
and then subscribe to the returned Flux
to initiate the stream.
Required properties:
gemfire.region.region-name
- The name of the existing remote region.gemfire.pool.host-addresses
- A comma delimited list ofhost:port
pairs. By default these are locator addresses but are cache server addresses if you setgemfire.pool.connect-type=server
.
For more information on the various options available, please see:
- GemFireSupplierProperties.java (
gemfire.supplier
)
Many of the options, common to functions that use VMware GemFire, are configured by several @ConfigurationProperties
classes which are included as needed:
- GemFireClientCacheProperties.java (
gemfire.client
) - GemFireRegionProperties.java (
gemfire.region
) - GemFirePoolProperties.java (
gemfire.pool
) - GemFireSecurityProperties.java (
gemfire.security
) - GemFireSslProperties.java (
gemfire.security.ssl
)
See this test suite for examples of how this supplier is used.