Friday 30 October 2015

Integrating Oracle Coherence with WebCenter Portal

Oracle Coherence is the cache tool of Oracle and is intended to store frequently used data of applications. In the case of WebCenter Portal, this product is crucial to achieve a good performance of the platform, so it is strongly recommended to configure Coherence with Portal installations. In this post I include some guidelines and tips to integrate Portal and Coherence.

Testing Coherence Configuration

Once Coherence has been installed, the tool must be tested to check it is properly configured. This link provides a good step-by-step test.

Integration with Content Presenter

Coherence is usually integrated with WebCenter Content via Content Presenter. This process is explained in detail by the A-Team in this post, basically it consists in editing the content-coherence-cache-config.xml file, create the jar library and add it to the Portal application. By configuring this, the retrieval of content from WebCenter Content would be reduced drastically by caching the Content Presenter items in Coherence.

Caching WebCenter Portal transactions

Now that content is cached, page loading time would have decreased, but in order to really improve performance, transactions should be cached too. Portal is usually integrated with external web services, retrieving information from them, this type of transactions are costly in time, due to the network communication with the third party environment and its processing time.
To cache those transactions, a generic application must be created using the CacheFactory class and others, which will implement the communciation with Coherence. Oracle official documentation provides a comprehensive guide to create a Coherence application here, including the tangosol-coherence-override.xml file. This application will be deployed as JAR library and included in the libraries of the WebCenter Portal application. Once these methods are accesible from the application, simple invocations are implemented to store (put) and retrieve (get) from Coherence.

public void put (Object key, Object o,long time);
Where key is the identificator, o is the value and time is the storage time.
 
Oracle Coherence is so flexible that it allows developers to cache objects. For instance, it may be convenient to cache a whole java object with the response of a web service, which would include all the information of a customer.
In this case, it is important to assign proper expiration times for objects, otherwise users would receive old wrong data. Ideally, that time could be high (days or months) if the modification of the data is done via the Portal application too, so developers would execute cache flush of an object every time it is updated; therefore the cached data would always be correct. Problems arise when that data is updated by third-party applications, out of the scope of WebCenter Portal.

It is advised to have different cache repositories for different expiration time, so there would be one for objects with 1 hour expiration, another one for 1 day, etc. This is supposed to increase performance of the tool in large implementations.

Coherence Administration Application 

Cache administration could be undertaken using a simple ADF application, where all the cache objects are displayed in a table, along with buttons that would allow to flush the whole cache or a specific element. The implementation is not complicated, just using loops to get all the objects and functions to perform the actions. This is very useful when Portal administrators have the need to solve an issue regarding a wrong cached object, they could search for the element and flush it; another scenario is when a massive update is performed in the systems and the whole cache turns invalid, it can be flushed completely with just one click. Also, it might be interesting to include an 'Add' button to create objects using a form. Obviously, this application must be user protected so just granted users can access.



Monitoring Coherence

Coherence can be monitored using jConsole, the configuration needed is not complicated and it is detailed in this document. After that, jConsole will display Coherence MBeans and clusters.

Another choice is to use Enterprise Manager as monitoring tool, as described in this A-Team post.

Conclusion

Considering the complexity of WebCenter Portal implementations, Oracle Coherence is a must to keep a good performance of the platform and reduce page load time. For example, the use of Coherence enabled a real Portal environment to reduce the loading time from 25 seconds to just 3.

References

Building your first Coherence application
Class CacheFactory
Coherence Monitoring Management in Oracle Enterprise Manager
Configure Coherence for Oracle WebCenter Portal Framework Content Presenter Task Flow
Oracle Coherence Overview
Testing a Coherence Installation
Using JMX to manage Coherence
Using WebCenter and Oracle Coherence Together – Discussion and How To