Gemfire - 缓存创建时出现 IllegalStateException

发布于 2024-11-30 06:29:53 字数 689 浏览 0 评论 0原文

我正在尝试运行 Gemfire 客户端应用程序,但在运行以下代码时遇到 IllegalStateException:

//clientPool is the name of the pool from the client
DynamicRegionFactory.Config config = new DynamicRegionFactory.Config(null,(String)"clientPool",false,true);
dynRegFact = DynamicRegionFactory.get();
dynRegFact.open(config);        
_cache = new ClientCacheFactory().set("locators", "")
                .set("mcast-port", "0").set("log-level", "error")
                .set("cache-xml-file", xmlFileName)
                .create();

线程“main”java.lang.IllegalStateException 中的异常:DynamicRegionFactory 的客户端池必须配置为启用队列设置为真的。

我不知道如何将启用队列设置为 true。我希望得到一些代码,而不是像“检查文档的这一部分”这样的答案。我已经到处找过了。

I'm trying to run a Gemfire client app but I'm getting an IllegalStateException when running the following code:

//clientPool is the name of the pool from the client
DynamicRegionFactory.Config config = new DynamicRegionFactory.Config(null,(String)"clientPool",false,true);
dynRegFact = DynamicRegionFactory.get();
dynRegFact.open(config);        
_cache = new ClientCacheFactory().set("locators", "")
                .set("mcast-port", "0").set("log-level", "error")
                .set("cache-xml-file", xmlFileName)
                .create();

Exception in thread "main" java.lang.IllegalStateException: The client pool of a DynamicRegionFactory must be configured with queue-enabled set to true.

I can't figure out how to set the queue-enabled to true. I would appreciate some code, not answers like "check this part of the documentation". I've already looked everywhere.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

所有深爱都是秘密 2024-12-07 06:29:53

您应该在池中启用订阅。只需将 subscription-enabled="true" 属性添加到您的池配置中即可。

注意:您的客户端应该支持交易。最好在缓存服务器上使用动态区域。从客户端调用远程函数。

示例:

功能:

public class CreateRegionFunction extends FunctionAdapter {

@Override
public void execute(FunctionContext fc) {
    String name = (String) fc.getArguments();
    Region reg = DynamicRegionFactory.get().createDynamicRegion("/parent",
            name);

    if (reg == null) {
        fc.getResultSender().lastResult("ERROR");
    } else {
        fc.getResultSender().lastResult("DONE");
    }
}

@Override
public String getId() {
    return "create-region-function";
}

}

服务器端:

CreateRegionFunction creatRegFun = new CreateRegionFunction(); 
FunctionService.registerFunction(creatRegFun);

在服务器缓存中添加动态区域工厂:

<dynamic-region-factory />

客户端:

FunctionService.onServer(PoolManager.find("poolName"))
     .withArgs("child")
     .execute("create-region-function")
     .getResult();

在这种情况下,不必使用 DynamicRegionFactory,您可以使用 RegionFactory 并创建根区域。

You should enable subscription in your pool. Just add subscription-enabled="true" attribute to your pool configuration.

Note: Your client should support transactions. It's better to use dynamic regions on cache servers. From client call remote function.

Example:

Function:

public class CreateRegionFunction extends FunctionAdapter {

@Override
public void execute(FunctionContext fc) {
    String name = (String) fc.getArguments();
    Region reg = DynamicRegionFactory.get().createDynamicRegion("/parent",
            name);

    if (reg == null) {
        fc.getResultSender().lastResult("ERROR");
    } else {
        fc.getResultSender().lastResult("DONE");
    }
}

@Override
public String getId() {
    return "create-region-function";
}

}

Server side:

CreateRegionFunction creatRegFun = new CreateRegionFunction(); 
FunctionService.registerFunction(creatRegFun);

Add dynamic-region-factory in your server cache:

<dynamic-region-factory />

Client side:

FunctionService.onServer(PoolManager.find("poolName"))
     .withArgs("child")
     .execute("create-region-function")
     .getResult();

In this case it's not obligatory to use DynamicRegionFactory, you can use RegionFactory and create root regions.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文