ignite队列是否有一些方法可以检查队列是否创建,就像缓存一样?
?对于IGNITE CACHE,我可以使用Somethin,例如:
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);
}
我不太了解您的代码。首先,以下代码段确定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
。请确保该队列不是早些时候创建的。