Open Source Projects:
Back to top

Hazelcast IBM Dynacache Provider

Mesut Celik March 08, 2017

IBM has a cache abstraction called Dynacache in Websphere Application Server(WAS) Distributions. That abstraction is handy if you want to use a configurable built-in cache solution in your JEE application deployed into WAS environment.

Following is the basic retrieval of built-in Dynacache provider via JNDI

private static DistributedObjectCache cache = retrieveDynacache();
    static DistributedObjectCache retrieveDynacache(){
      try {
        InitialContext ic = new InitialContext();
        return (DistributedObjectCache) ic.lookup("services/cache/distributedmap");
      } catch (NamingException e) {
         // catch the exception

IBM Dynacache is used internally to improve performance of WAS Deployment. Here are the list of features to boost the performance.

Hazelcast Dynacache Provider

IBM WAS has two Dynacache Providers

  1. Default Provider
  2. eXtreme Scale Dynacache Provider

Default Provider is the one which ships with IBM WAS and has limited capabilities. It only provides in-process caching solution. If you are in a distributed environment, you may want to use a distributed caching solution. IBM has a solution to that with its eXtreme Scale Dynacache Provider. In case you have an eXtreme Scale cluster, you can use store your caches across eXtreme Scale cluster.

Besides those solutions, Hazelcast has developed its own Dynacache Provider for users interested in keeping their cache data in Hazelcast Clusters. Hazelcast Dynacache Provider has been released as OSS under Apache 2.0 License.

Configuring in WAS Liberty Profile

Download and install WebSphere Liberty version from here. From this point on, I will refer to the directory you have installed WebSphere Liberty as $LIBERTY_HOME.

Install Hazelcast Dynacache plugin from the GitHub releases page and install it to Liberty as follows:

$LIBERTY_HOME/bin/featureManager install hazelcast-dynacache-0.2.esa

Create a server named server1:

$LIBERTY_HOME/bin/server create server1

Open up $LIBERTY_HOME/usr/servers/server1/server.xml in your text editor and replace its content with following:

        <!-- hazelcast-dynacache depends on this -->
    <httpEndpoint id="defaultHttpEndpoint" host="*" httpPort="9080">
        <tcpOptions soReuseAddr="true"/>
    <logging traceSpecification="com.hazelcast.*=finest=enabled"
        traceFileName="trace.log" maxFileSize="20"
        maxFiles="20" traceFormat="BASIC"/>

Using Hazelcast Cache Provider

Clone Hazelcast Code Samples repository from Github and build Dynacache Client project:

git clone ch hazelcast-code-samples/hazelcast-integration/dynacache mvn clean package

Copy the resulting WAR file under the dropins folder of Liberty server we had created:

cp target/dynacache-client-0.1-SNAPSHOT.war $LIBERTY_HOME/usr/servers/server1/dropins/dynacache-client.war

Add the following to a file named jvm.options under $LIBERTY_HOME/usr/servers/server1/:

    -Dhazelcast.client.config=<path to hazelcast-code-samples dir>/hazelcast-integration/dynacache/hz-client.xml

Next, we start a Hazelcast 3.8 cluster, with the default configuration (which starts up a member on port 5701).

Start the WebSphere Liberty server:

$LIBERTY_HOME/bin/server start server1

Navigate to http://localhost:9080/dynacache-client on your browser and you will see the following output:

PutResult: the value
    the key => the value
    the key 2 => the value 2
    Invalidation took place...
    the key => null
    the key2 => the value 2
    SomeClass{field1='field 1', field2='field2updated'}

Note that our web application has no direct dependency on Hazelcast, it doesn’t contain hazelcast.jar. It uses interface of Dynacache to retrieve the underlying Hazelcast IMap.


Hazelcast is leading open source IMDG in the market. If you have an JEE application which is using dynacache API, you can simply switch to Hazelcast Dynacache provider to use Hazelcast as distributed caching solution. Hazelcast Dynacache Provider currently supports Hazelcast Client/Server topology but you can always ask for feature requests by submitting a github issue.

Here are the links to stay in touch with Hazelcast Community.

About the Author

About the Author

Mesut Celik

Latest Blogs

Hazelcast on IBM Cloud Private

View all blogs by the author

Subscribe to the newsletter

Follow us on: