jgroups-all.jar
concurrent.jar
oscache-2.1.jar
日志包等不一一列出。
hibernate使用oscache作为二级缓存,首先在hibernate配置二级缓存:
<property name="hibernateProperties"> <props> <prop key="hibernate.show_sql"> true </prop> <prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop> <prop key="hibernate.jdbc.fetch_size">25</prop> <prop key="hibernate.jdbc.batch_size">50</prop> <prop key="hibernate.cache.use_query_cache">true</prop> <prop key="hibernate.connection.pool_size">50</prop> <prop key="hibernate.cache.provider_class">org.hibernate.cache.OSCacheProvider</prop> <prop key="hibernate.jdbc.use_scrollable_resultset">true</prop> <prop key="hibernate.generate_statistics">true</prop> <prop key="current_session_context_class">thread</prop> <prop key="hibernate.bytecode.provider">cglib</prop> <!-- <prop key="hibernate.default_schema">${jdbc.username}</prop>--> </props> </property>
使用JGroups(消息可靠)做为消息中间件。
在oscache.properties配置:
cache.memory=true cache.event.listeners=com.opensymphony.oscache.plugins.clustersupport.JavaGroupsBroadcastingListener cache.algorithm=com.opensymphony.oscache.base.algorithm.LRUCache cache.blocking=true cache.capacity=10000 cache.cluster.properties=UDP(mcast_addr=231.12.21.132;mcast_port=45566;ip_ttl=32;\ mcast_send_buf_size=150000;mcast_recv_buf_size=80000):\ PING(timeout=2000;num_initial_members=3):\ MERGE2(min_interval=5000;max_interval=10000):\ FD_SOCK:VERIFY_SUSPECT(timeout=1500):\ pbcast.NAKACK(gc_lag=50;retransmit_timeout=300,600,1200,2400,4800;max_xmit_size=8192):\ UNICAST(timeout=300,600,1200,2400):\ pbcast.STABLE(desired_avg_gossip=20000):\ FRAG(frag_size=8096;down_thread=false;up_thread=false):\ pbcast.GMS(join_timeout=5000;join_retry_timeout=2000;shun=false;print_local_addr=true) cache.cluster.multicast.ip=231.12.21.132
配置过程中遇到问题:
1、hibernate配置文件缓存如果配置为<cache usage="read-write"/>则发现缓存无法同步。
故需要设置为:nonstrict-read-write
2、concurrent.jar不能缺。
3、win7下出现failed to join /224.0.0.75:7500 on net5: java.net.SocketException: Unrecognized Windows Sockets error: 0: no Inet4Address associated with interface异常。
需要在jvm配置-Djava.net.preferIPv4Stack=true参数。