在我的基于sping的项目(spring version 4.1.5.FINAL)中,我使用的是ehcache-core version 2.6.10,ehcache-jgroupsreplication versione 1.7和jgroups 3.1.0.FINAL
这是我的XML ehcache配置:
<?xml version="1.0" encoding="UTF-8"?>
<ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://ehcache.org/ehcache.xsd" name="webCache" >
<diskStore path="java.io.tmpdir/webCache"/>
<cacheManagerPeerProviderFactory class="net.sf.ehcache.distribution.jgroups.JGroupsCacheManagerPeerProviderFactory" properties="udp.xml"/>
<cache name="it.test.cache.CustomCache"
maxElementsInMemory="1000"
eternal="false"
timeToIdleSeconds="600"
timeToLiveSeconds="6000"
overflowToDisk="true">
<cacheEventListenerFactory class="net.sf.ehcache.distribution.jgroups.JGroupsCacheReplicatorFactory" properties="replicateAsynchronously=true,replicatePuts=true,replicateUpdates=true,replicateUpdatesViaCopy=false,replicateRemovals=true" />
</cache>
</ehcache>
这是我的upd.xml配置:
<config xmlns="urn:org:jgroups"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="urn:org:jgroups http://www.jgroups.org/schema/jgroups.xsd">
<UDP
mcast_port="${jgroups.udp.mcast_port:45588}"
tos="8"
ucast_recv_buf_size="200K"
ucast_send_buf_size="200K"
mcast_recv_buf_size="200K"
mcast_send_buf_size="200K"
max_bundle_size="64K"
max_bundle_timeout="30"
ip_ttl="${jgroups.udp.ip_ttl:2}"
enable_diagnostics="true"
thread_naming_pattern="cl"
timer_type="new"
timer.min_threads="4"
timer.max_threads="10"
timer.keep_alive_time="3000"
timer.queue_max_size="500"
thread_pool.enabled="true"
thread_pool.min_threads="2"
thread_pool.max_threads="8"
thread_pool.keep_alive_time="5000"
thread_pool.queue_enabled="true"
thread_pool.queue_max_size="10000"
thread_pool.rejection_policy="discard"
oob_thread_pool.enabled="true"
oob_thread_pool.min_threads="1"
oob_thread_pool.max_threads="8"
oob_thread_pool.keep_alive_time="5000"
oob_thread_pool.queue_enabled="false"
oob_thread_pool.queue_max_size="100"
oob_thread_pool.rejection_policy="Run"/>
<PING />
<MERGE3 max_interval="30000"
min_interval="10000"/>
<FD_SOCK/>
<FD_ALL/>
<VERIFY_SUSPECT timeout="1500" />
<BARRIER />
<pbcast.NAKACK use_mcast_xmit="true"
retransmit_timeout="300,600,1200"
discard_delivered_msgs="true"/>
<UNICAST/>
<pbcast.STABLE stability_delay="1000" desired_avg_gossip="50000"
max_bytes="4M"/>
<pbcast.GMS print_local_addr="true" join_timeout="3000"
view_bundling="true"/>
<UFC max_credits="2M"
min_threshold="0.4"/>
<MFC max_credits="2M"
min_threshold="0.4"/>
<FRAG2 frag_size="60K" />
<pbcast.STATE_TRANSFER />
</config>
在我的spring xml上下文中,我有以下内容(我只会放一个spring上下文文件的片段):
<bean id="settaSystemProps" name="settaSystemProps" class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
<property name="targetObject">
<bean class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
<property name="targetClass" value="java.lang.System" />
<property name="targetMethod" value="getProperties" />
</bean>
</property>
<property
name="targetMethod" value="putAll" />
<property
name="arguments">
<util:properties>
<prop key="jgroups.logging.log_factory_class">it.test.cache.replication.jgroups.log.logback.impl.LogbackLogImpl</prop>
<prop key="java.net.preferIPv4Stack">true</prop>
</util:properties>
</property>
</bean>
<bean id="webCacheManager" class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean" depends-on="settaSystemProps">
<property name="configLocation" value="classpath:webCoMiEhCacheCfg.xml"/>
</bean>
遗憾的是,通过使用此配置,我无法在群集中发送/接收消息
当我启动我的tomcat时,我看到以下打印(并且它没有使用我的自定义日志):
feb 27,2015 10:31:18 AM org.jgroups.logging.JDKLogImpl错误严重: 向集群发送消息失败(65字节):java.lang.Exception: dest = / 228.8.8.8:45588(68字节),原因:java.io.IOException:无效 争论 feb 27,2015 10:31:19 AM org.jgroups.logging.JDKLogImpl错误 严重:向群集发送消息失败(65字节): java.lang.Exception:dest = / 228.8.8.8:45588(68字节),原因: java.io.IOException:参数无效 2015年2月27日上午10:31:28 org.jgroups.logging.JDKLogImpl错误严重:发送消息失败 cluster(65 bytes):java.lang.Exception:dest = / 228.8.8.8:45588(68 bytes),原因:java.io.IOException:无效的参数feb 27,2015 上午10:31:28 org.jgroups.logging.JDKLogImpl错误严重:发送失败 消息到集群(65字节):java.lang.Exception: dest = / 228.8.8.8:45588(68字节),原因:java.io.IOException:无效 参数
谁能告诉我哪里错了?我需要的是在由2个节点组成的集群上同步EhCache
任何人都可以向我提供工作配置样本吗?
谢谢
安吉洛
答案 0 :(得分:1)
启动实例时的输出是什么?我想你可能还在使用IPv6。你能使用-Djava.net.preferIPv4Stack = true而不是在XML中定义它吗?