Let us see how to add coherence node to Soa 12c’s integrated Weblogic coherence cluster.
We will put value in out-of-box “adapter-local” cache from the added node and access that value from a SOA Composite using Coherence Adapter.
We will use the out-of-box cache config from Soa 12c’s Coherence Adapter. It can be obtained from <home>\soa\soa\connectors\CoherenceAdapter.rar archive.
Following is the content of config file. Copy the contents and save it as cache-config.xml in <home>/coherence/bin directory
<?xml version="1.0"?> <!DOCTYPE cache-config SYSTEM "cache-config.dtd"> <cache-config> <caching-scheme-mapping> <cache-mapping> <cache-name>adapter-local</cache-name> <scheme-name>transactional</scheme-name> </cache-mapping> </caching-scheme-mapping> <caching-schemes> <transactional-scheme> <scheme-name>transactional</scheme-name> <service-name>SOAAdapterTransactionalCache</service-name> <autostart>true</autostart> </transactional-scheme> </caching-schemes> </cache-config>
We will configure Coherence cluster for Multicast Address. Login to Weblogic Console and expand “Environment -> Coherence Clusters”. Click on “defaultCoherenceCluster”.
Make the highlighted changes. Save the configuration and restart server.
Let us start one more coherence server from the command line. Coherence command line scripts can be found at <home>/coherence/bin . Take a back up of “coherence.cmd” file.
Edit the “coherence.cmd” and make the following changes
Add the following line in the file.
set coherence_opts=-Dtangosol.coherence.cluster=defaultCoherenceCluster -Dtangosol.coherence.clusteraddress=239.192.0.0 -Dtangosol.coherence.clusterport=51203 -Dtangosol.coherence.cacheconfig=cache-config.xml
Modify the following line from
set java_opts=-Dcoherence.distributed.localstorage=false %jmxproperties%
to
set java_opts=-Dcoherence.distributed.localstorage=true %jmxproperties%
We are storage enabling our node. This way we will connect to “adapter-local” cache from command line, put a value and retrieve it from SOA composite using Coherence adapter.
Modify the following line from
"%java_exec%" -server -showversion %java_opts% -cp "%coherence_home%\lib\coherence.jar" com.tangosol.net.CacheFactory %1
to
"%java_exec%" -server -showversion %java_opts% -cp "%coherence_home%\lib\coherence.jar" %coherence_opts% com.tangosol.net.CacheFactory %1
From a command prompt , execute coherence.cmd script. It should join the existing cluster and Member Id should be 2. If you see as “1”, it means it has not joined the cluster.
Let us connect to “adapter-local” cache (specified in config file) and list the contents of key value pairs.
To connect type “cache adapter-local” in the prompt. We should get output like the following
We can type “list” to see all the values stored. We will be getting nothing as it was created just now.
Let us put, get and list values in the cache with the commands
put username Krishna
get username
list
We have added an extra node to join the default Coherence cluster (started as part of the Integrated Weblogic server.). We have added values to the adapter-local cache from the node.
In the next blog, we will see how to retrieve the value using a SOA Composite & Coherence Adapter.