英文:
Hazelcast client time to live setup for individual client
问题
以下是翻译好的内容:
我在使用 SpringBoot 与 Hazelcast。在我的设置中,我有一个正在运行的 Hazelcast 服务器(3.12.6),我正在将其与 SpringBoot 应用程序中的 Hazelcast 客户端连接起来。
hazelcast-client.yaml
hazelcast-client:
network:
cluster-members:
- 127.0.0.1
smart-routing: false
我已经在 Hazelcast 服务器中检查了设置,在 hazelcast.xml
中有一个全局配置,用于配置 Time to Live(TTL) 配置。
hazelcast.xml
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ 版权所有(c)2008-2018,Hazelcast,Inc. 保留所有权利。
~
~ 在 Apache 许可证下,版本 2.0(“许可证”)的许可下,此文件仅供遵守许可证。
~ 您可以在以下位置获取许可证副本:
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ 除非适用法律要求或书面同意,否则按“原样”分发的软件
~ 没有任何形式的明示或暗示担保或条件。
~ 有关特定语言的权限,请参阅许可证。
-->
<hazelcast xsi:schemaLocation="http://www.hazelcast.com/schema/config hazelcast-config-3.11.xsd"
xmlns="http://www.hazelcast.com/schema/config"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<group>
<name>dev</name>
</group>
<management-center enabled="true">http://mc_server:8080/hazelcast-mancenter</management-center>
<map name="default">
<time-to-live-seconds>10</time-to-live-seconds>
<max-idle-seconds>10</max-idle-seconds>
</map>
</hazelcast>
我的问题是:
是否有任何方式可以使用我的 SpringBoot 客户端在服务器上配置 Time to Live 和其他设置?
英文:
I am using SpringBoot with Hazelcast.
In my setup I have one Hazelcast server(3.12.6) up and running I am connecting that with Hazelcast client in my SpringBoot application.
hazelcast-client.yaml
hazelcast-client:
network:
cluster-members:
- 127.0.0.1
smart-routing: false
I have checked the setup in Hazelcast server, there is a global configuration in hazelcast.xml
that helps in configuration of Time to live configuration.
hazelcast.xml
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright (c) 2008-2018, Hazelcast, Inc. All Rights Reserved.
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
<hazelcast xsi:schemaLocation="http://www.hazelcast.com/schema/config hazelcast-config-3.11.xsd"
xmlns="http://www.hazelcast.com/schema/config"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<group>
<name>dev</name>
</group>
<management-center enabled="true">http://mc_server:8080/hazelcast-mancenter</management-center>
<map name="default">
<time-to-live-seconds>10</time-to-live-seconds>
<max-idle-seconds>10</max-idle-seconds>
</map>
</hazelcast>
My question is:
Is there any way I can configure time to live and other settings using my springboot client on my server?
答案1
得分: 0
以下是来自Hazelcast Client的动态配置示例。
HazelcastInstance client = HazelcastClient.newHazelcastClient();
MapConfig mCfg = new MapConfig("test");
mCfg.setTimeToLiveSeconds(15);
client.getConfig().addMapConfig(mCfg);
HazelcastClient.shutdownAll();
详细信息和限制请参阅此处 - https://docs.hazelcast.org/docs/3.12.6/manual/html-single/index.html#dynamically-adding-data-structure-configuration-on-a-cluster
谢谢,Sharath
英文:
Here is an example of Dynamic configuration from a Hazelcast Client.
HazelcastInstance client = HazelcastClient.newHazelcastClient();
MapConfig mCfg = new MapConfig("test");
mCfg.setTimeToLiveSeconds(15);
client.getConfig().addMapConfig(mCfg);
HazelcastClient.shutdownAll();
Details and limitations are here - https://docs.hazelcast.org/docs/3.12.6/manual/html-single/index.html#dynamically-adding-data-structure-configuration-on-a-cluster
Thanks, Sharath
专注分享java语言的经验与见解,让所有开发者获益!
评论