Spring Infinispan Integration on Wildfly

This is a sample spring boot application that demonstrates Infinispan caching integration on Wildfly servers. It works for both local and distributed caching on both standalone and clustered Wildfly instances.

This application is tested on Wildfly 10.1.0.Final.

Running the application

The application war file can be built using maven.

    mvn clean install

The application also requires a custom cache container, below is how it can be created on Wildfly.

Standalone server mode

When running the server in a standalone mode add the following cache container config in standalone.xml file.

    <cache-container name="mycache" aliases="ha-partition" default-cache="default" module="org.wildfly.clustering.server">
        <local-cache name="default" />
    </cache-container>

Clustered server mode

For clustered mode, the server must be run with full-ha profile. And add the following cache container to standalone-full-ha.xml

    <cache-container name="mycache" aliases="ha-partition" default-cache="default" module="org.wildfly.clustering.server">
        <transport lock-timeout="60000"/>
        <replicated-cache name="default" mode="SYNC">
            <transaction mode="BATCH"/>
        </replicated-cache>
    </cache-container>

Usage

The application exposes the following rest endpoints to add, retrieve and remove cache entries

GET /rest/cache/{key}
PUT /rest/cache/{key}/{value}
DELETE /rest/cache/{key}

Resources

Visit the following blog post for more details

Spring and Infinispan Integration on Wildfly Cluster