5

Hi i am new to oracle coherence,

Question 1 : my scenario is, i have to implement the oracle coherence replicated cache in my webapplication.(with weblogic server).the coherence should be the part of the weblogic server means when i start the weblogic server the coherence should start (both should run in the single JVM).please help me how to do it ?

Question 2 : whether i need a database to maintain the records or oracle coherence it self maintain in file system ? if yes means how and what will happen for the cached data when i shutdown the server?

Saiyansharwan
  • 71
  • 1
  • 2
  • 5

2 Answers2

2

Q1:

I would describe it in couple of steps:

  1. Place coherence.jar in the classpath. Depending on specific case it can be WLS classpath or application's classpath. Unless you want to share coherence node between many applications it is often a better idea to put it to application's classpath. It also has other advantages like easier maintenance.
  2. Prepare your own cache configuration for the replicated topology. You can skip this step if you want to use coherence default cache configuration coherence-cache-config.xml which includes replicated topology, but keep in mind that your cache name must start with repl- and this is in general not recommended for production. Otherwise put the following to your custom-cache-config.xml file and add it to your application's classpath.

    <?xml version="1.0"?>
    
    <cache-config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns="http://xmlns.oracle.com/coherence/coherence-cache-config"
       xsi:schemaLocation="http://xmlns.oracle.com/coherence/coherence-cache-config
       coherence-cache-config.xsd">
    
       <caching-scheme-mapping>
          <cache-mapping>
             <cache-name>my-repl-cache</cache-name>
             <scheme-name>replicated</scheme-name>
          </cache-mapping>
       </caching-scheme-mapping>
    
       <caching-schemes>
          <replicated-scheme>
             <scheme-name>replicated</scheme-name>
             <backing-map-scheme>
                <local-scheme/>
             </backing-map-scheme>
             <autostart>true</autostart>
          </replicated-scheme>
       </caching-schemes>
    </cache-config>
    
  3. Create a ContextListener for your application and place the following code into contextInitialized method:

    // join existing cluster or form a new one
    CacheFactory.ensureCluster();
    
  4. Start your WLS with the following option:

    -Dtangosol.coherence.cacheconfig=custom-cache-config.xml
    
  5. Deploy and start your application (possibly on many servers)

Q2:

In general coherence is in memory solution and doesn't persist data by default. If you need to manage data in persistent store you can look into CacheStore interface. This is described here in the documentation.

Keep in mind that often you have more than one coherence node in the cluster so you will not lose your data when you shutdown one of them because data is always stored also in other JVM(s). When you restart your node it will join the cluster and your data will be there.

Mihau
  • 56
  • 1
  • HI Thanks for your useful information. could you please give me some links to create a web application using coherence+weblogic server+eclipse – Saiyansharwan Nov 22 '11 at 04:15
  • Normally in your WLS application you can use Coherence like in any standalone Java application (additionally inside container you can use some specific features like Coherence*Web). The comprehensive source of truth is [here](http://coherence.oracle.com/display/COH/Oracle+Coherence+Knowledge+Base+Home) and [here](http://docs.oracle.com/cd/E24290_01/index.htm). I would suggest to start with GSG and some tutorials. [Coherence GSG](http://docs.oracle.com/cd/E24290_01/coh.371/e22840/toc.htm), [Tutorial](http://docs.oracle.com/cd/E24290_01/coh.371/e22622/toc.htm) – Mihau Nov 30 '11 at 08:28
1

Starting with WebLogic 12.1.2, there is excellent Coherence integration via the "Coherence Containers" functionality of WebLogic, in addition to the ActiveCache feature of WebLogic. Here is a URL for the container feature: http://docs.oracle.com/middleware/1212/wls/WLCOH/deploy-wls-coherence.htm

For the sake of full disclosure, I work at Oracle. The opinions and views expressed in this post are my own, and do not necessarily reflect the opinions or views of my employer.

cpurdy
  • 1,177
  • 5
  • 12
  • Just curious. What would you recommend for caching data returned for a GET request so that we only have to run the code for the request once ever? – Slartibartfast Jan 08 '16 at 21:24