How to Integrate OSB with Remote Coherence Cache

Insights

In my previous blog, Optimising OSB Performance with Remote Coherence Cache, I detailed how separating out Coherence JVM from OSB JVM can enhance the performance of Oracle Service Bus (OSB). In this blog, I will demonstrate how to achieve this outcome with a step-by-step guide.

The below diagram illustrates how we can configure OSB to cache results on a separate Coherence JVM managed by WebLogic.

1. Setting-Up Node Manager

Node manager needs to be installed as an operating system service that starts up automatically once the machine on which it has been installed starts up. Node manager controls all other services of WebLogic domain. The steps required for installing node manager as a service can be found on Oracle Documentation.

2. Adding a Machine to the domain

A node manager always sits on top of every machine in a WebLogic domain. Node manager can be sued to control all the servers running on a single machine. For adding a machine to the node manager, navigate to WebLogic console: http://windows:101/console

Once the console opens up, expand the environment part of the domain from the left hand panel of the console. Click on machine.

  • Provide your machine name and the operating system. In the case of Windows, just keep it as others.
  • Click next and navigate to the next page.
  • Alter the type to Plain from SSL. It is recommended to have the type as SSL, but setting up SSL requires the host to have a client cert which needs to be updated in the WebLogic server. [We will skip this step]
  • Listen address should be the address on which the node manager is running.
  • Click on finish.
  • Get into the monitoring, and navigate to NodeManagerStatus. Ideally it should be reachable. But we need to do some more setup before making it reachable.

Navigate back to home page. Click on Servers. In the configuration page, add the machine to the AdminServer. The configuration should now look like the image below:

Once this setup is done, we need to enrol this domain with node manager. There are various ways to do this but we will use WebLogic scripting.

Navigate to $WLSHOME/server/bin and run the script set WLSEnv.cmd which sets the environment. Once done, from command line, run the command

java weblogic.WLST

Once this is done, it connects to WebLogic scripting tool in an offline mode. Issue the command:

nmEnroll(‘$DomHome’)

This enrols the domain to the node manager.

Now, we need to connect to the node manager from the WebLogic scripting tool:

> nmConnect(‘$USERNAME’,’$PWD’,’$NMHOST’,’$NMPORT’,’$DOMAINNAME’, ‘$DOMAINPATH’,’plain’)

Once done, we need to set up the boot properties for the servers. Otherwise the node manager starts up the server with the default password, which may not work because the domain may have a different password.

Navigate to: $DOMAINHOME/servers/AdminServer/data/nodemanager

Create a file with name: boot.properties

Type in the following two lines in plain text:

username=weblogic password=<password>

Note: Do not worry about the security aspect. Once the node manager is restarted, the plain text is converted into AES128 encrypted text.

Restart your node manager from services. Once done, get into the wlst command line and connect to nodemanager again. Now you can start your server with the following command:

> nmStart(‘ip-dev-osb-adm’)

This should create a <servername>.out file for the server.

Once the server has started, we can enable other options for node manager to maintain a hawk eye on the server and take actions on the servers in the case of failures. A few of the important properties that need to get into the nodemanager.properties file are:

  • CrashRecoveryEnabled=true
  • StartScriptEnabled=true

We need to restart the node manager service to pick up the latest values.

Once this set up is done, we need to now set up the remote coherence server for the domain.

3. Setting up Coherence Cluster and Coherence Server

As previously mentioned, it is recommended that you have a coherence cache mechanism that has its own jvm so that all the cache result set is loaded on a different jvm from the apps server. It is very important that the parameters we provide to the coherence servers are well suited for the cache to hold good.

Setting up Coherence Cluster

Log on to the server console. Expand Environment from the left hand panel of the console. Click on Coherence Cluster

  • In the coherence cluster, click on ‘New’. Provide the name of the cluster you want to have, in this case it is ip-osb-coherence
  • Click on next.
  • Provide the host name of the machine [or virtual ip VIP if you have one pre-configured for the cluster in your DNS table]. In this case it is windows.
  • Provide a unicast port for which the cluster can listen to. In this case it is 9001.
  • Also provide a multicast address and port if you want to make your coherence servers listen to a multicast ip instead of unicast. It is highly recommended that we use unicast address for the coherence clusters and multicast address for the application servers.
  • Target the cluster to the admin server or manager server depending upon your environment topology.

The cluster configuration should look something like what’s in the image below.

Setting up Coherence Server

To set up the coherence server, go back to the home page of the Console and expand Environment tab of the domain and click on Coherence Servers.

  • Name: Provide a name for the server [ip-osb-coherence-ms1]
  • Machine: Pick the machine that needs to be targeted to [windows]
  • Cluster: Pick the name of the cluster created [ip-osb-coherence]
  • Unicast Address: Same as the cluster host [windows]
  • Unicast Port: Same as the cluster port [9001]

The server configuration should resemble the image below:

Once created, click on the Server Start tab of the configuration of the coherence server. We need to add coherence server as a client to OSB as it should perform result caching remotely.

Provide the settings as depicted in image for the server start properties:

  • Java Home: C:OracleJRockit
  • Java Vendor: Oracle
  • BEA Home: $MWH
  • Root Directory: $DOMAIN_HOME

Now we need to provide the classpath for coherence server to start up. It is absolutely mandatory for the coherence server to pick up the right coherence jars and the coherence client jars.

The following jars needs to be added for the coherence server to start up as a service provider to OSB:

PS: Replace C:/Oracle/SOA11G_WLS_OEPE/ with $MWH directory and :/Oracle/SOA11G_WLS_OEPE/OSB11G_OEPE with $OSB_HOME

Now we need to set the right arguments for the JVM. Since my java vendor is JRockit – Oracle, here are the arguments that have been passed in:

Click on save and activate the changes.

Setting up Coherence Override File

Once the server configuration is done, we need to set up the domain override configuration that will govern the coherence server.

Navigate to $DOMAIN_HOME/config/osb/coherence

There you would find two files:

  • osb-coherence-override.xml
  • osb-coherence-cache-config.xml

Open osb-coherence-override.xml and perform the changes to suit the coherence configuration.

Once done, save the file. Go back to the domain console and click on the coherence server. Navigate to the Control tab, and click on Start. If everything is right the server will start up well.

Now we need to get the right arguments for the WebLogic server where OSB is deployed.

Setting up WebLogic Java Arguments

Open setDomainEnv.cmd/.sh file and navigate to the Java Arguments line.

Add the following properties:

The property for the distributed storage in WebLogic should be set to false; otherwise it will start using the local cache instead of the jvm of the coherence server which we do not want.

The last step would be to enable caching in Oracle Service Bus. For that we need to navigate to the service bus console http://windows:101/sbconsole

Click on Operations > Global Settings > Enable Result Caching [Check Mark and save the settings]

Author Details

Souvik Mukherjee
Principal Consultant (Architecture & Integration) Souvik is a SOA Consultant with over eight years’ experience in enterprise systems integration. Souvik has worked on a variety of medium to large sized projects in various sectors and has experience across all phases of the software development lifecycle. Souvik specialises in middleware technologies and the architecture, design and implementation of service-oriented architecture solutions.

You might be interested in these related insights