Thursday, November 05, 2009

SOA Suite 10.3.5.1 released: certified with Weblogic Server 10.3.1

SOA Suite 10.1.3.5.1 (aka Oracle Fusion Middleware 1ogr3) has been released. Finally, Oracle BPEL Manager, Oracle ESB, Oracle Rules, OWSM components and all versioned 10.1.3.5.1 are certified with WLS 10.3.1.

Tuesday, November 03, 2009

Oracle Coherence*Web: easy in-memory session management in a clustered environment

Oracle Coherence contains the Oracle Coherence*Web session management module. Oracle Coherence*Web provides in-memory session data management that allows your website to benefit from the high-performance, reliable, high available and scalable data grid solution provided by Oracle Coherence to easily share and manage session data in an application server cluster

In this blog posting, I will use a simple JSF web application deployed on a Weblogic Server 11g instance to show you how easy it is to set-up Oracle Coherence*Web to store session data in a Oracle Coherence data grid.

Coherence and Weblogic 11g configuration
I have used Coherence 3.5.2 and Weblogic 11g (10.3.1) to set up this demo. Coherence 3.5.2 can be downloaded from here and Weblogic Server 11g (10.3.1) from here. Make sure you have patched your weblogic server with patch 6W2W if you use Weblogic Server 10.3

Deploy the coherence-web-spi.war as a shared library to your Weblogic server instance. To start a Oracle Coherence web-session cache server, create a cache-websession-server.sh in the root of your COHERENCE_HOME. Copy/paste the following contents to cache-websession-server.sh:

#!/bin/sh

# This will start a cache server

# specify the Coherence installation directory
COHERENCE_HOME=.

# specify the JVM heap size
MEMORY=512m

if [ ! -f ${COHERENCE_HOME}/bin/cache-server.sh ]; then
echo "coherence.sh: must be run from the Coherence installation directory."
exit
fi

if [ -f $JAVA_HOME/bin/java ]; then
JAVAEXEC=$JAVA_HOME/bin/java
else
JAVAEXEC=java
fi

JAVA_OPTS="-Xms$MEMORY -Xmx$MEMORY"

$JAVAEXEC -server -showversion $JAVA_OPTS -cp "$COHERENCE_HOME/lib/coherence.jar:$COHERENCE_HOME/lib/coherence-web-spi.war" -Dtangosol.coherence.management.remote=true -Dtangosol.coherence.cacheconfig=WEB-INF/classes/session-cache-config.xml -Dtangosol.coherence.session.localstorage=true com.tangosol.net.DefaultCacheServer

That's all what's needed to set up your test environment.

JSF
The web application is a JSF web application consisting of a simple JSF page that displays a button to increase a counter. The counter value is stored in a JSF managed bean (session-scoped) attribute. The managed bean is session scoped to ensure that the counter is saved in the Coherence data grid. Storing the complete managed bean is not a must-have requirement, but it is an easy way and suitable for this simple case. Oracle Coherence provides functionality to determine which objects have to be stored in the Oracle Coherence data grid and which not. This is explained later in this posting.

I assume you know how to make such a simple JSF application so I will skip that. The only thing you have to make sure is that you add the coherence.jar library to your project.

To enable Coherence*Web for in-memory session management, the only thing you have to add is a weblogic.xml file and add the following library reference to it:


<library-ref>
<library-name>coherence-web-spi</library-name>
<specification-version>1.0.0.0</specification-version>
<implementation-version>1.0.0.0</implementation-version>
<exact-match>false</exact-match>
</library-ref>
<library-ref>
<library-name>jsf</library-name>
<specification-version>1.2</specification-version>
<implementation-version>1.2.3.2</implementation-version>
<exact-match>false</exact-match>
</library-ref>

(The JSF reference makes the JSF libraries available to web application)

Bundle the application in a war file and deploy it to the Weblogic Server Domain in the same server in which you have deployed the coherence-web-spi.war.

Note: The JSF application makes use of WAR-scoped Coherence session management. Other variants are EAR-scoped and application server scoped. The last two variant allows you to share session data between web applications...but be careful with this feature!

Test
Start 1 or more Coherence web-session-cache instances to create a Oracle Coherence data-grid by executing the cache-websession-server.sh several times...(notice how easy it is to create a Oracle Coherence cluster and check the logging output to see the Coherence actions to manage the cluster) . Now we have a data grid to store the session data in, you can browse to your web application and hit the button several times to set the counter value. As a final test: shutdown the Weblogic server....wait a second...start the server again and open your web application...the previous counter value is still there!

Other features & benefits
- Session management models
Oracle Coherence*Web supports three different session management models to support different types of web applications:

  • The traditional model -> suitable for small applications with small session objects

  • The monolithic model -> same as traditional model but without object sharing issues

  • The split model -> suitable for web applications with large session object

- Distribution controller
The Coherence*Web distributed controller functionality allows you to manage which objects has to be stored locally in the server heap (only local accessible) or distributed (shared across multiple servers) in the Coherence data grid and at what moment in the life-cycle of a user session a object should be stored in a Coherence data grid. This feature has several useful use cases, for example to reduce the migration effort to migrate a non-distributed application to a distributed one.