Products
Clients
Extensions
APIs
With the recent release of Spring Integration for GemFire, you may be wondering how you can use it to simplify integrating GemFire into your data pipelines. This guide will walk you through an example using Spring integration to tie together RabbitMQ, GemFire, and a Postgres database.
Before we begin, we first need to choose a version of Spring Integration for GemFire. Currently, there are three releases available, all of which are version 1.0.0.
This example uses Spring Integration 6.1 for and GemFire 10.0.
This example consists of only two classes – IntegratorApplication and Order. IntegratorApplication is a Spring Boot application that drives the example, and Order is a simple domain class representing an order. When the application starts, we create a queue named “orderQueue” in RabbitMQ. For convenience, we let Spring Boot create an orders region in GemFire and an orders table in Postgres automatically.
To start our example, there is a scheduled method that creates a randomized Order every two seconds and sends it to the “orderQueue.” Then, using an adapter supplied by spring-integration-amqp, we get the data from our queue and put it into a publish-subscribe channel, which will allow the message to be received by multiple subscribers–in this case, allowing it to be handled and logged to the console while still continuing down our pipeline. The Order will then be processed by a CacheWritingMessageHandler, which is supplied by spring-integration-gemfire to listen on a channel and write to a GemFire Region. Next, a CacheListeningMessageProducer is triggered by a new Order being written to GemFire and sends the new Order to a direct channel – which only allows a single recipient, unlike a publish-subscribe channel – where it is handled by a JdbcMessageHandler which writes the Order to our Postgres database.
The flow of data looks approximately like this:
Note: it’s possible to complete this guide without Docker if you have GemFire, RabbitMQ, and Postgres installed
spring-integration/gemfire-rabbit-postgres-integration
docker run -p 5672:5672 -d rabbitmq
docker run -it -e 'ACCEPT_TERMS=y' --rm -p 10334:10334 -p 40404:40404 -p 7070:7070 gemfire/gemfire gfsh
start locator --hostname-for-clients=localhost
configure pdx --read-serialized=true
start server --hostname-for-clients=localhost
docker run --name postgres -e POSTGRES_PASSWORD=postgres -p 5432:5432 -d postgres
psql
docker exec -it postgres psql -U postgres
query --query="select * from /orders"
select * from orders;
This is a basic example that illustrates how to use GemFire as both a consumer and producer of data within Spring Integration and how it can fit in with other technologies like RabbitMQ and Postgres/JDBC.