点火队列是否有一些方法来检查是否创建了队列,就像缓存一样

时间:2018-04-27 09:18:38

标签: apache ignite

点火队列是否有一些方法来检查是否创建了队列,就像缓存一样?

对于点燃缓存,我可以使用像:

这样的东西
        if( txInfoCache.get(txType) == null ) {
            txInfoCache.put(txType, new TreeMap<Long, InfoRecord>());
        }

但是当我尝试使用它来处理队列时,它只是创建一个新的

        CollectionConfiguration colCfg = new CollectionConfiguration();

        IgniteQueue<InfoRecord>  queue =
                ignite.queue("ResultRecordQueue_" + txType, 0, null);

        // never go into this judge
        if (queue == null) {
            queue = ignite.queue("ResultRecordQueue_" + txType, 0, colCfg);
        }

1 个答案:

答案 0 :(得分:2)

我不太了解你的代码。首先,以下代码片段确定txInfoCache缓存是否包含给定密钥txType的条目,如果它不包含与密钥关联的条目,则它将指定的密钥与给定密钥相关联值。

if(txInfoCache.get(txType) == null) {
    txInfoCache.put(txType, new TreeMap<Long, InfoRecord>());
}

可以更改为txInfoCache.putIfAbsent(txType, new TreeMap<Long, InfoRecord>())

至于你问题的第二部分,我刚检查了Apache Ignite 2.4,它运行良好。如果命名队列不存在且Ignite.queue(String name, int cap, @Nullable CollectionConfiguration cfg)null,则CollectionConfiguration方法返回null。请确保之前未创建此队列。

相关问题