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

标签 java 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);
        }

最佳答案

我不太明白你的代码。首先,以下代码片段确定 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如果指定队列不存在且 CollectionConfigurationnull 。请确保该队列不是之前创建的。

关于java - 点燃队列是否有一些方法来检查队列是否创建,就像缓存一样,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50059165/

相关文章:

java - Java 的 UI 控件

installation - 如何在二进制发行版中安装 Apache Ignite Web 控制台模块

java - 定义缓存时如何从自定义类获取 QueryFields?

go - Apache ignite SQL 插入失败

java - 我自己的 eclipse 编辑器中 Properties View 的事件

java - 在 jetty 中部署 webapps 和 websockets

java - 使用 Active Directory SSO 从 Microsoft IE 到 Java 服务器时,为什么会收到 GSSException?

java - 如何使用 OpenTok 收听来 self 的应用程序的传入视频通话?

java - 理解 ignite 中的 BinaryObject