gpt4 book ai didi

java - 使用 DataStream 的 addData 点燃事务。可能的?

转载 作者:太空宇宙 更新时间:2023-11-04 09:59:16 25 4
gpt4 key购买 nike

我们想要将批量数据加载到ignite缓存中,因此我们使用了data Streamer(stmr.addData)而不是cache.put(相对较慢)。现在想要在我的批量加载操作上应用事务。这发生在我的数据流处理案例中,同时使用cache.put操作。

我的代码:

CacheConfiguration<String, Person> cacheConfiguration = new 
CacheConfiguration<>("PersonCache");
cacheConfiguration.setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL);
IgniteTransactions transactions = ignite.transactions();
Transaction tx = transactions.txStart();
while (resultSet.next()) {
Persion person = new Persion();
persion.setName(name);
persion.setAge(age);
dataStreamer.addData(personKey, person);
}
tx.commit();

//while cache.put(personKey, person) is giving me transnational output

最佳答案

我认为不可能让 DataStreamer 以这种方式使用事务。 DataStreamer 的重点是批量发送数据,而不是逐个条目发送数据。

为什么您希望此操作是事务性的?我认为 StreamReceiverallowOverwrite 更适合您的需求。

关于java - 使用 DataStream 的 addData 点燃事务。可能的?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53707570/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com