Clustered ehcache using jgroups multicast.

Required dependencies:

    <dependency>
        <groupId>net.sf.ehcache</groupId>
        <artifactId>ehcache-core</artifactId>
        <version>2.5.0</version>
    </dependency>

    <dependency>
        <groupId>net.sf.ehcache</groupId>
        <artifactId>ehcache-jgroupsreplication</artifactId>
        <version>1.5</version>
    </dependency>

Configuration:

  • global:
    <cacheManagerPeerProviderFactory
        class="net.sf.ehcache.distribution.jgroups.JGroupsCacheManagerPeerProviderFactory"
        properties="connect=UDP(mcast_addr=${multicastGroupAddress};mcast_port=${multicastGroupPort};):PING:
        MERGE2:FD_SOCK:VERIFY_SUSPECT:pbcast.NAKACK:UNICAST:pbcast.STABLE:FRAG2:pbcast.GMS"
        propertySeparator="::"/>
  • for each clustered cache:
    <cacheEventListenerFactory
        class="net.sf.ehcache.distribution.jgroups.JGroupsCacheReplicatorFactory"/>

properties are read simply from what’s being set by -D when invoking java (or e.g. in jboss properties-service.xml)

Advertisements

Hibernate log4j configuration

To make hibernate log absolutely everything it may log add a following line to log4j configuration:

<logger name="org.hibernate">
   <level value="ALL" />
   <appender-ref ref="FILE"/>
</logger>

FILE should be replaced with the name of the logger you want to use.

E.g. on JBoss the log4j configuration is placed in $JBOSS_HOME/server/[server configuration name]/conf/jboss-log4j.xml