【发布时间】:2018-05-29 15:27:37
【问题描述】:
我将一个应用程序迁移到 Spring Boot,包括从 XML 迁移到 Java 配置。该应用程序使用 Hazelcast 并且确实有效。但是,我再也看不到 JConsole 中的 Hazelcast MBean。关于启用 JMX,我唯一能找到的就是属性
properties.put("hazelcast.jmx", true);
但这无济于事。这是迁移前的配置:
<hz:hazelcast id="hzInstance">
<hz:config>
<hz:group name="gsynth" password="gsynth"/>
<hz:properties>
<hz:property name="hazelcast.logging.type">slf4j</hz:property>
<hz:property name="hazelcast.jmx">true</hz:property>
<hz:property name="hazelcast.version.check.enabled">false</hz:property>
<hz:property name="hazelcast.icmp.enabled">true</hz:property>
<hz:property name="hazelcast.shutdownhook.enabled">true</hz:property>
<hz:property name="hazelcast.max.operation.timeout">60000</hz:property>
<hz:property name="hazelcast.restart.on.max.idle">true</hz:property>
</hz:properties>
<hz:network port="5701" port-auto-increment="false">
<hz:join>
<hz:multicast enabled="false"/>
<hz:tcp-ip enabled="true">
<hz:members>${members.list}</hz:members>
</hz:tcp-ip>
</hz:join>
</hz:network>
</hz:config>
</hz:hazelcast>
<hz:map id="serviceHash" instance-ref="hzInstance" name="service-hash"/>
<hz:map id="persisterHash" instance-ref="hzInstance" name="persister-hash"/>
现在看起来像这样:
public class HazelcastConfig
{
@Bean
public HazelcastInstance hzInstance(Config hzConfig)
{
return Hazelcast.newHazelcastInstance(hzConfig);
}
@Bean
public Config hzConfig(@Value("${members.list}") String membersList)
{
Properties properties = new Properties();
properties.put("hazelcast.logging.type", "slf4j");
properties.put("hazelcast.jmx", true);
properties.put("hazelcast.version.check.enabled", false);
properties.put("hazelcast.icmp.enabled", true);
properties.put("hazelcast.shutdownhook.enabled", true);
properties.put("hazelcast.max.operation.timeout", 60000);
properties.put("hazelcast.restart.on.max.idle", true);
return new Config().setGroupConfig(new GroupConfig().setName("gsynth").setPassword("gsynth")).setProperties(
properties).setNetworkConfig(
new NetworkConfig().setPort(5701).setPortAutoIncrement(false).setJoin(
new JoinConfig().setMulticastConfig(new MulticastConfig().setEnabled(false)).setTcpIpConfig(
new TcpIpConfig().setEnabled(true).addMember(membersList))));
}
@Bean
public IMap serviceHash(HazelcastInstance hzInstance)
{
return hzInstance.getMap("service-hash");
}
@Bean
public IMap persisterHash(HazelcastInstance hzInstance)
{
return hzInstance.getMap("persister-hash");
}
}
感谢您的帮助!
【问题讨论】:
标签: java spring spring-boot jmx hazelcast