我需要在一个tomcat服务器中创建两个hazelcast实例。我把榛子与春天融为一体。以下是配置文件。
hazelcast.properties
#First instance properties
hz.instance.name = mi
hz.group.name = mi
hz.group.password = password
hz.management.center.enabled = true
hz.management.center.url = http://localhost:8085/mancenter
hz.network.port = 5701
hz.network.port.auto.increment = true
hz.tcp.ip.enabled = false
hz.members = 127.0.0.1
hz.multicast = true
hz.multicast.group = 224.2.2.3
hz.multicast.port= 54327
hz.multicast.timetolive=32
hz.multicast.timeout.seconds=2
#Second instance properties
hz.instance.nameOne = miOne
hz.group.name = mi
hz.group.password = password
hz.management.center.enabled = true
hz.management.center.url = http://localhost:8085/mancenter
hz.network.port = 5701
hz.network.port.auto.increment = true
hz.tcp.ip.enabled = false
hz.members = 127.0.0.1
hz.multicast = true
hz.multicast.group = 224.2.2.3
hz.multicast.port= 54327
hz.multicast.timetolive=32
hz.multicast.timeout.seconds=2
hazelcast.xml
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:hz="http://www.hazelcast.com/schema/spring"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
http://www.hazelcast.com/schema/spring http://www.hazelcast.com/schema/spring/hazelcast-spring.xsd">
<hz:hazelcast id="instance">
<hz:config>
<hz:instance-name>${hz.instance.name}</hz:instance-name>
<hz:group name="${hz.group.name}" password="${hz.group.password}" />
<hz:management-center enabled="${hz.management.center.enabled}"
url="${hz.management.center.url}" />
<hz:network port="${hz.network.port}" port-auto-increment="${hz.network.port.auto.increment}">
<hz:join>
<hz:multicast enabled="${hz.multicast}" />
<hz:tcp-ip enabled="${hz.tcp.ip.enabled}">
<hz:members>${hz.members}</hz:members>
</hz:tcp-ip>
</hz:join>
</hz:network>
</hz:config>
</hz:hazelcast>
<hz:hazelcast id="instanceOne">
<hz:config>
<hz:instance-name>${hz.instance.nameOne}</hz:instance-name>
<hz:group name="${hz.group.name}" password="${hz.group.password}" />
<hz:management-center enabled="${hz.management.center.enabled}"
url="${hz.management.center.url}" />
<hz:network port="${hz.network.port}" port-auto-increment="${hz.network.port.auto.increment}">
<hz:join>
<hz:multicast enabled="${hz.multicast}" />
<hz:tcp-ip enabled="${hz.tcp.ip.enabled}">
<hz:members>${hz.members}</hz:members>
</hz:tcp-ip>
</hz:join>
</hz:network>
</hz:config>
</hz:hazelcast>
<hz:map id="map" instance-ref="instance" name="Map" />
</beans>
在hazelcast.xml中,如果你看到我已经注册了两个hazelcast实例
instance
&amp; instanceOne
。 instanceOne
几乎就是复制配置。 instance
如果我删除instanceOne
,则第二个成员/实例无法启动。假设我必须在单个JVM中创建hazelcast的n
个实例。我是否在n
中注册了hazelcast.xml
次实例,或者有更好的方法来配置bean吗?