用Redis Redisson客户端执行批次查询永远悬挂
我有一个包含数百万条记录的清单列表,我想使用 Redisson Batch 命令在 Redis 中批量插入/合并这些记录。 下面是batch.execute
语句的代码,
public void upsertInventoryInBatches(final List<ItemInventory> itemInventory) throws ExecutionException, InterruptedException {
RBatch batch = redissonClient.createBatch(BatchOptions.defaults().responseTimeout(300, TimeUnit.SECONDS));
RMapAsync<String, ItemInventory> map = batch.getMap(IMSConstant.REDIS_INVENTORY_MAP);
try {
for (ItemInventory item : itemInventory) {
map.mergeAsync(item.getKey(), item, (existing, newValue) -> {
if (existing == null) {
return newValue;
} else {
if (existing.getQuantity() == newValue.getQuantity()
&& existing.getMinMRP() == newValue.getMinMRP()) {
return existing;
}
existing.setQuantity(item.getQuantity());
existing.setMinMRP(item.getMinMRP());
existing.setEarliestExpiryDate(item.getEarliestExpiryDate());
existing.setVersion(item.getVersion());
return existing;
}
});
}
var res = batch.execute(); // Hangs with no result and no error
} catch (Exception e) {
System.out.println(e.getMessage());
}
它挂起,没有错误,也没有输出。 寻求关于我做错了什么的指导。 batch.getMap(IMSConstant.REDIS_INVENTORY_MAP).putAsync(item.getKey(), item)
工作正常,但我想合并这些值。如果用redisson不可能,是否可以通过任何redis java客户端?
I have an inventory list of Millions of records that I want to insert/merge in batches in Redis using Redisson Batch command.
below is the code
public void upsertInventoryInBatches(final List<ItemInventory> itemInventory) throws ExecutionException, InterruptedException {
RBatch batch = redissonClient.createBatch(BatchOptions.defaults().responseTimeout(300, TimeUnit.SECONDS));
RMapAsync<String, ItemInventory> map = batch.getMap(IMSConstant.REDIS_INVENTORY_MAP);
try {
for (ItemInventory item : itemInventory) {
map.mergeAsync(item.getKey(), item, (existing, newValue) -> {
if (existing == null) {
return newValue;
} else {
if (existing.getQuantity() == newValue.getQuantity()
&& existing.getMinMRP() == newValue.getMinMRP()) {
return existing;
}
existing.setQuantity(item.getQuantity());
existing.setMinMRP(item.getMinMRP());
existing.setEarliestExpiryDate(item.getEarliestExpiryDate());
existing.setVersion(item.getVersion());
return existing;
}
});
}
var res = batch.execute(); // Hangs with no result and no error
} catch (Exception e) {
System.out.println(e.getMessage());
}
thebatch.execute
statement just hangs with no error and no output.
Looking for guidance on what I am doing wrong.batch.getMap(IMSConstant.REDIS_INVENTORY_MAP).putAsync(item.getKey(), item)
works fine but I want to merge the values. if its not possible with redisson, Is it possible via any redis java client?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论