Posted by Marcel Friedmann on 7:37 PM with 1 comment
WebSphere Application Server provides basic cache functionality for java ee applications. One cache functionality is the "Object Cache" which allows applications to programatically use a container hosted cache instance. When using WebSphere Application Server Network Deployment the object cache can also be used as a clustered cache (invalidating & replicating). It therefore can be used as an alternative to Infinispan or EhCache.
This object cache can also be used as an 2nd-Level-Cache for Hibernate 3. A Hibernate 4 adapter is currently not available.
How to setup an object cache instance
To create a basic/non-clustered Object Cache navigate toRessources > Object cache instances > New ...
A Object cache instance can be limited by the amount of items in the cacheandby the cache size (in MB). However only the amount of items is mandatory configuration (default is 2000 items).
Click>OK and >Savethe Changes.
The ObjectCache can be used programmatically with theDistrubedMap-Interface. Please refer tothis ibm knowledge base articlefor more informationen - it is quite straight forward.
A sample project with a servlet putting and getting values to/from the object cache can bedownloaded here. The servlet urls is "http://<host>:<port>/object-cache-test/SimpleServletTest".
To monitor the cache instance you should use the Cache Monitor provided with the WebSphere Application Server.
Go toApplications > New Application > New Enterprise Applicationand select the CacheMonitor.ear which is located in "WebSphere-Install-Root"/installableApps/CacheMonitor.ear
Click>Nextand select the "Fast Path". The installation does not require any special configurations. After the installation process is finished click>Save.
To actually see the statistics of object cache instances it is nesseccary to extend the basic cache monitor. Whitout this extention the cache monitor is only able to view content of servlet cache instances.
Download theExtended Cache Monitor packagefor that (IBM-ID needed for download!). For WebSphere Application Server 8.5.5 download the WebSphere Application 7 package (cachemonitor7_package.zip) which should work in most cases.
Extract the cachemonitor7_package.zip.
Go toApplications > WebSphere enterprise applications
Select theDynamic Cache MonitorApplication and select "Update".
SelectReplace, add, or delete multiple filesand browse to the cachemonitor7_update.zipwithin the downloaded package and click>Nextand>Ok.
When the update process is finished click Save directly to the master configuration.
Restart the application server.
The cache monitor is availiable with the url http://<host>:<port>/cachemonitor
[Images] Cover picture by Markus Spiske (http://www.raumrot.com/)