简体   繁体   中英

Ehcache Distributed Multiple channel

I am using ehcache in ditributed mode . The caches are synchronized by channel .

<cacheManagerPeerProviderFactory
    class="net.sf.ehcache.distribution.jgroups.JGroupsCacheManagerPeerProviderFactory"
    properties="channelName=CHANNEL1:connect=UDP(mcast_port=45568)"
    propertySeparator=":" />

For a new requirement , i need to synch with two channels : CHANNEL1 and CHANNEL2 .

Is this possible ? if yes , how i can do that ?

Thanks in advance

Usually One instance of cacheManagerPeerProviderFactory is used to replicate ( or Synchronize) number of caches across cluster. In that case, "channelName=CHANNEL1:" is more like simply giving a name. I don't think ehCache supports multiple channels.

If you're requirement is to have some replication specific one channel, you can try one of the following

  • Run two EhCache Managers in the same application each with it's ehcache.xml, One for the specific replication logic, and one for the common replication logic of caches.
  • You will have only one cache manager, but your ehcache.xml will vary in a way that, you won't include the cache ( which requires specific replication logic) with in the third application.

First one is more cleaner approach. You can have multiple EhcacheManagers with Spring in following way,

<ehcache:annotation-driven cache-manager="ehCacheManager1" />

<bean id="ehCacheManager1" class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean">
    <property name="configLocation" value="classpath:ehcache-1.xml" />
</bean>

<bean id="ehCacheManager2" class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean">
    <property name="configLocation" value="classpath:ehcache-2.xml" />
</bean>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM