1

我正在尝试运行 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。

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

4

1 回答 1

2

您应该在您的池中启用订阅。只需将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 并创建根区域。

于 2011-08-19T09:20:07.310 回答