Monday, September 13, 2010

Coherence: running 2 coh clusters in OSB

Step 1:

backup the old library 3.5.2b463 existing at
/Oracle/Middleware/coherence_3.5/lib/

and replace it with the "latest stable" 3.5.3/465p6

We should definitely avoid using 2 different versions of Coherence for the OSB and the Custom cluster, just to make our life simpler.

Now, OSB should start the internal Coherence cluster using the 3.5.3/465p6 version (check the MS logs)

Step 2:

put somewhere in the MS classpath the tangosol-coherence-override.xml for the Custom node.
This will not interfere with the built-in OSB Coherence, which is loading its config from
com.bea.alsb.coherence-impl.jar!/tangosol-coherence-override.xml and $DOMAIN_HOME/config/osb/coherence/osb-coherence-override.xml

Check the line
Created a new cluster "OSB-cluster" with Member(Id=1, Timestamp=bla, Address=127.0.0.1:7890..)


which corresponds to the $DOMAIN_HOME/config/osb/coherence/osb-coherence-override.xml settings



Step 3:

Add /Oracle/Middleware/coherence_3.5/lib/coherence.jar and /Oracle/Middleware/coherence_3.5/lib/je.jar to the MS classpath, so that we don't need to deploy these JARs in the OSB project making the JavaCallout to the Custom cluster.
REMEMBER: having these libraries in the CLASSPATH doesn't mean that the OSB internal cluster will load the Coherence classes in the System Classloader! The ALSB Coherence Cache Provider EAR specifies to load them in the EAR classloader!

If you are using this utility, add to MS classpath also /coh-sl/lib/coherence-serialization-support.jar which contains the PofSerialized classes (they are available here
http://coherence.politext.info/pof-serializer-generator-java-apt-plugin )



Step 4:
code your Java callout class to return instances of
org.apache.xmlbeans.XmlObject
Library Path: /Oracle/Middleware/modules/com.bea.core.xml.xmlbeans_2.2.0.0.jar

in practice:

import org.apache.xmlbeans.XmlObject;

public static XmlObject myJavaCallout() {
.... invoke your code getting data from Coherence Cache....
XmlObject returnObject = XmlObject.Factory.parse("");
return returnObject;



and make sure that in your OSB Java Callout you DON'T return by reference.



You will see that at the first invocation of Coherence you will join the Coherence Cluster, from the second onwards this will not happen.