[英]Does ignite queue has some method to check if the queue created or not, just like the cache
像缓存一样,点燃队列是否有某种方法可以检查是否创建了队列?
对于点火缓存,我可以使用一些类似的东西:
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
。 请确保此队列不是较早创建的。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.