Warming a Coherence Cache using HotCache

As well as using HotCache to synchronise a Coherence cache's with database tables in real-time, it can also be used to warm the cache's, by loading an initial dataset. The nice thing about this approach is that cache warming is just an extension to the setup for cache synchronisation. This blog post outlines the necessary steps to setup cache warming using HotCache and GoldenGate and a high level overview is shown below.

Cache Warming Using HotCache

These instructions assume that you already have HotCache setup. To find out how to do this please see the documentation here or the online HotCache tutorial here. The username/password used in this HotCache example is also application/oracle and the GoldenGate home ($GG_HOME) is /u01/app/ogg.

Step 1 - Extract the initial data set from the database

The first thing to do is extract the values from a database table to GoldenGate trail files, using an initial-load Extract to extract source records from the source tables and write them to an extract file in canonical format. Here is a GoldenGate intial-load Extract parameter file called init_load.prm for the extraction of the table data;

  -- This is an initial load extract init_load
  -- SOURCEISTABLE parameter indicates Source is table not redo logs
  USERID application, PASSWORD oracle
  -- EXTFILE parameter indicates Destination of files to write data
  -- Note: set MEGABYTES parameter to a maximum file size relative
  -- to the amount of source data being extracted
  EXTFILE /u01/app/ogg/dirdat/IL, maxfiles 9999, MEGABYTES 5, PURGE
  TABLE application.*


Note: the parameter files need to be placed in the $GG_HOME/dirprm directory. 

These parameters are used by a GoldenGate initial load extraction process which is run directly from the command line outside of the usual GGSCI GoldenGate command line utility using the commands below;

  cd $GG_HOME
  extract paramfile /u01/app/ogg/dirprm/init_load.prm reportfile /u01/app/ogg/dirrpt/init_load.rpt

After running this command there will be 1 or more trail files named IL0001, IL0002 etc in the $GG_HOME/dirdat directory. If no files are generated then review the init_load.rpt file under the $GG_HOME/dirrpt directory

Step 2 - Load the initial data set into Coherence

To load these files into the Coherence cache copy and rename (swaping  the name hotcache for initcach) the exiting HotCache GoldenGate parameter file and properties file, for instance hotcache.prm and hotcache.properties. Examples are shown below;

  -- Extraction process name, change this to initcach from hotcache
  EXTRACT initcach
  USERID application, PASSWORD oracle
  GetEnv (JAVA_HOME)
  GetEnv (PATH)
  TABLE application.*;


Note: this parameter file need to be placed in the $GG_HOME/dirprm directory and the name of the prm file can only have 8 characters

  # List of active event handlers. Handlers not in the list are ignored.
  # Coherence cache updater
  # Native JNI library properties
  jvm.bootoptions=-Xmx32M -Xms32M -Dlog4j.configuration=debug-log4j.properties -Dlog4j.debug=true -Dtoplink.goldengate.persistence-unit=HOL9436  -Dtangosol.coherence.wka= -Dtangosol.coherence.wka.port=9000 -Dtangosol.coherence.cluster=CoherenceCluster -Dtangosol.coherence.cacheconfig=/home/oracle/workspace/JCacheClient/src/custom-coherence-cache-config.xml -Dtangosol.pof.config=META-INF/pof-config.xml -Djava.class.path=/u01/app/ogg/dirprm:/u01/app/oracle/product/11.2.0/xe/jdbc/lib/ojdbc6.jar:/u01/app/ogg/ggjava/ggjava.jar:/u01/Oracle/Middleware/Oracle_Home/coherence/lib/coherence.jar:/u01/Oracle/Middleware/Oracle_Home/coherence/lib/coherence-jcache.jar:/u01/Oracle/Middleware/Oracle_Home/coherence/lib/cache-api.jar:/u01/Oracle/Middleware/Oracle_Home/oracle_common/modules/javax.persistence_2.1.jar:/u01/Oracle/Middleware/Oracle_Home/oracle_common/modules/oracle.toplink_12.1.3/eclipselink.jar:/u01/Oracle/Middleware/Oracle_Home/oracle_common/modules/oracle.toplink_12.1.3/toplink-grid.jar:/home/oracle/workspace/HOL9436/output/package/HOL9436.jar:/u01/Oracle/Middleware/Oracle_Home/user_projects/applications/wl_server/examples/src/examples/coherence/managed-coherence-servers/common/build/gar/ExampleGAR.gar


Note: the parameters of the jvm boot parameter will obviously vary depending on your setup. This properties file, like the prm files, needs to be placed in the $GG_HOME/dirprm directory

The next step is to register these parameters (initcach.prm) with an extraction process that can be started from the GoldenGate command line GGSCI. Here is the GoldenGate commands to do this;

add extract initcach, exttrailsource /u01/app/ogg/dirdat/IL

This command can be added using the GoldenGate Command Line Interpreter (GGSCI), started as follows;

  cd $GG_HOME

Or added to a script, for instance add_initcach.ggsci, and run as follows;

  cd $GG_HOME
  ./ggsci << EOF
  OBEY /home/oracle/workspace/HOL9436/src/ogg/add_initcach.ggsci

These 2 configuration files will be used by this initcach process that reads the trail files created by initial load extraction process and loads them into Coherence. the GoldenGate commands need to perform this loading are as follows;

  -- Start the GG manager process, if not already running
  start mgr
  status mgr
  -- Start the loading of the trail files into Coherence
  start extract initcach
  info all

These commands can be added to a file, for instance called start_initcach.ggsci, and executed using the following commands;

  cd $GG_HOME
  ./ggsci << EOF
  OBEY /home/oracle/workspace/HOL9436/src/ogg/start_initcach.ggsci

Once run the contents of the extracted trail files will be loaded into Coherence.

For Completeness

Now there are a few other steps to consider. Initially before we extract our initial data set we might want to clear up any previous trail files and remove any previously registered extraction processes. The following GoldenGate script can do this;

  rm -rf $GG_HOME/dirdat/IL*

(shell command) 

  cd $GG_HOME
  stop extract initcach
  delete extract initcach


We will probably also want to stop the loading process after the trail files have been loaded into Coherence. The following GoldenGate command script will perform this task;

  stop extract initcach
  info all


Warming a Coherence cache AND Synchronising it with a Database

If you want to warm your Coherence cache using the above scripts you will usually want to keep the cache synchronized at the same time. So how do you do both without overritting new data with stale data? The answer is to choregraph the operations of each step to ensure they run in the correct sequence. The logical sequence of operations you need to run is as follows;
  1. Start the HotCache extraction processes (capturing database changes and writing them to trail files), but do not start loading these into Coherence
  2. Start the cache warming extraction processes to extract the initial data set and write it to trail files (Step 1 above)
  3. Run the loading process, to populate Coherence with the base data set (Step 2 above).
  4. Check the initial load has completed correctly - for instance by comparing the number of rows extracted from the database in the GoldenGate report file (rpt) with the number of cache entries in the target cache using the Coherence console and a command file to query the cache size.
  5. Stop the GoldenGate loading process (stop_initcach.ggsci
  6. Start the HotCache GoldenGate process to load the changes into the target Coherence cache 


The process of warming a Coherence cache from a database and then synchronizing it in real-time is straight-forward, based largely on configuration and uses a proven set of technologies. A Coherence cluster could also be restarted and re-populated from and initial data set without the extraction process having to be re-run. However, this setup should be tested for performance and throughput to make sure that the initial load times meet your specific SLA's. 

Finally, I'd like to thank Davinder Mundy from the Oracle Data Integration team for all his help pulling together these examples and hope you find them useful. More information about GoldenGate can be found on our OTN site: http://www.oracle.com/technetwork/middleware/goldengate/overview/index.html

Join the discussion

Comments ( 1 )
  • Sylwek Thursday, September 17, 2015


    can we discuss details?

    I'm doing currently similar project, we want to avoid self development of warmer.

    I like this approach, but i have some questions.



Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.