[英]Gemfire - IllegalStateException on cache create
I'm trying to run a Gemfire client app but I'm getting an IllegalStateException when running the following code: 我正在尝试运行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();
Exception in thread "main" java.lang.IllegalStateException: The client pool of a DynamicRegionFactory must be configured with queue-enabled set to true. 线程“主”中的异常java.lang.IllegalStateException:DynamicRegionFactory的客户端池必须配置为queue-enabled设置为true。
I can't figure out how to set the queue-enabled to true. 我不知道如何将启用队列设置为true。 I would appreciate some code, not answers like "check this part of the documentation". 我会喜欢一些代码,而不是“检查文档的这一部分”之类的答案。 I've already looked everywhere. 我已经到处都看过了。
You should enable subscription in your pool. 您应该在池中启用订阅。 Just add subscription-enabled="true" attribute to your pool configuration. 只需在您的池配置中添加subscription-enabled =“ true”属性即可。
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. 在这种情况下,不必使用DynamicRegionFactory,可以使用RegionFactory并创建根区域。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.