Coherence Spring Integration

Coherence Spring Integration

Orache coherence is #1 In-Memory cache solution across Conventional and Cloud Environments and it’s very popular in enterprise wide caching solution provider. It’s key component of Oracle cloud enterprise application Foundation which predictably scales applications to meet cloud demand and mobile computing on shared services and infrastructure. Most of the companies now a days some kind of caching machanism to store data in cache. Having knowlege of cache is mandatory if you are in information technology field. In this Coherence Spring Integration demo I will show you how coherence works, how to store data in cahce, how to retrieve data from cache including create new cache etc…

Note: You will need coherence jars to run this application which you can download from this link

  • Coherence in-memory Data Grid sample diagram:

Coherence Spring Integration

Important configuration: Coherence use Portable Object Format (POF) to serialize and deserialize data to the cache so first you will have to set up model class which you want to serialize to the cache.

  • Create maven project name: CoherencePOFSerializationCache and below is final project structure:

Coherence Spring Integration

  • pom.xml:

First create model class which will be serialize to the cache:

  • Prices.java:

As this is very simple POJA wtih attribute related to stock price. Now we know that this the class we will be seriliazing to the cache. Next you will have to create PricesSerializer which will implements PofSerializer and this interface has two method: serialize and deserialize which you will have implement it as below to store and get data from the cache.

  • PricesSerializer.java:

Very important file: Now we have created out Serilization logic next create pof-config file and include below:

  • custom-types-pof-config.xml

  • Because we are integrating with Spring let’s create spring-context.xml which will be our IOC container:

  • main.properties where we will our keep value which will be used in application:

  • log4j2.xml to logging information:

  • CacheLoader.java is our business class where we wil be performing all our logic to store data in cache, load data from cache, print data from cache, clear data from cache as you see below:

  • Finally write main class MainCacheApplicationStarter.java to test our application:

  • Very very important: Before running MainCacheApplicationStarter.java class you will have to set VM argument as below and don’t forget to replace cahce URL with your company URL. If you are not sure what to pass please contact your company cache administrator he will provide you this URL:

  • That’s it. To run this application right click MainCacheApplicationStarter.java and run as java application and if everything goes well you will see out from your cache and in my case it was like below as I am just giving you short screen shot because console was very big:

Coherence Spring Integration

download Download Project:   CoherencePOFSerializationCache

2 thoughts on “Coherence Spring Integration

  1. Nice example,

    From above oracle coherence how can I find more details about the below dependencies?

    com.javahonk.clusterAPI
    ClusterClient
    ${clusterAPI.version}

    com.javahonk.clusterAPI
    ClusterInfoInvocation
    ${clusterAPI.version}

    com.javahonk.galaxy
    eqd
    ${galaxy.version}

    com.javahonk.galaxy
    eqdframework
    ${galaxy.version}

Leave a Reply

Your email address will not be published. Required fields are marked *