In this post we will show how we can do the following :
- Integrate spring boot with Apache Ignite
- How to enable and use persistent durable memory feature of Apache Ignite which can persist your cache data to the file disk to survive crash or restart so you can avoid data losing.
- How to execute SQL queries over ignite caches
- How to unit test and integration test ignite with spring boot
- Simple Jenkins pipeline reference
- Code repository in GitHub : GithubRepo
what is Ignite durable memory ?
Apache Ignite memory-centric platform is based on the durable memory architecture that allows storing and processing data and indexes both in memory and on disk when the Ignite Native Persistence feature is enabled. The durable memory architecture helps achieve in-memory performance with the durability of disk using all the available resources of the cluster
What is ignite data-grid SQL queries ?
Ignite supports a very elegant query API with support for Predicate-based Scan Queries, SQL Queries (ANSI-99 compliant), and Text Queries. For SQL queries ignites supports in-memory indexing, so all the data lookups are extremely fast. If you are caching your data in off-heap memory, then query indexes will also be cached in off-heap memory as well.
Ignite also provides support for custom indexing via
more information on : https://apacheignite.readme.io/docs/cache-queries
So to have Apache Ignite server node integrated and started in your spring boot app we need to do the following :
- Add the following maven dependencies to your spring boot app pom file
- Define ignite configuration via java DSL for better portability and management as a spring configuration and the properties values will be loaded from the application.yml file :
- then you can just inject ignite instance as a Spring bean which make unit testing much easier
How to enable Ignite durable memory :
How to use Ignite SQL queries over in memory storage:
How to do atomic thread safe action over the same record via cache invoke API:
How to unit test Apache ignite usage in spring boot service :
How to trigger integration test with Ignite, check test resources as well :
How to run and test the application over swagger rest api :
- build the project via maven : mvn clean install
- you can run it from IDEA via AlertManagerApplication.java or via java -jar jarName
- swagger which contain the REST API and REST API model documentation will be accessible on the URL below where you can start triggering different REST API calls exposed by the spring boot app:
- if you STOP the app or restart it and do query again , you will find all created entities from last run so it survived the crash plus any possible restart
- you can build a portable docker image of the whole app using maven Spotify docker plugin if you wish