You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在Ignite 2.15中设置系统属性IGNITE_ALLOW_ATOMIC_OPS_IN_TX=true

Ignite 2.15 开启事务内原子缓存操作的系统属性设置方法

要启用Ignite 2.15中事务内的原子缓存操作,你可以通过以下几种方式设置IGNITE_ALLOW_ATOMIC_OPS_IN_TX=true系统属性:

1. JVM启动参数设置

在启动Ignite节点时,直接通过JVM参数指定该属性:

java -DIGNITE_ALLOW_ATOMIC_OPS_IN_TX=true -jar ignite.jar

如果是嵌入式部署(比如在应用中启动Ignite),需要在IDE的VM选项或应用启动脚本中添加该参数。

2. 代码中提前设置

在调用Ignition.start()初始化Ignite节点之前,通过Java代码动态设置系统属性:

public static void main(String[] args) {
    // 必须在启动Ignite前设置该属性
    System.setProperty("IGNITE_ALLOW_ATOMIC_OPS_IN_TX", "true");
    
    Ignite ignite = Ignition.start();
}

3. XML配置文件设置

如果使用XML配置文件启动Ignite,可以通过Spring的MethodInvokingFactoryBean来设置系统属性:

<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://www.springframework.org/schema/beans
                           http://www.springframework.org/schema/beans/spring-beans.xsd">

    <!-- 配置系统属性 -->
    <bean class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
        <property name="targetClass" value="java.lang.System"/>
        <property name="targetMethod" value="setProperty"/>
        <property name="arguments">
            <list>
                <value>IGNITE_ALLOW_ATOMIC_OPS_IN_TX</value>
                <value>true</value>
            </list>
        </property>
    </bean>

    <!-- Ignite节点核心配置 -->
    <bean id="ignite.cfg" class="org.apache.ignite.configuration.IgniteConfiguration">
        <!-- 你的其他节点配置项 -->
    </bean>
</beans>

注意事项

  • 集群内所有节点都需要设置该属性,否则可能因节点行为不一致导致异常
  • 该属性仅在Ignite 2.15及更高版本生效,你的环境已经满足要求
  • 启用后,事务内的原子缓存操作(如putIfAbsent、getAndPut等)会被纳入事务上下文,随事务提交或回滚统一处理

内容的提问来源于stack exchange,提问作者Choco

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.07 08:22:40