簡體   English   中英

Gemfire-緩存創建時發生IllegalStateException

[英]Gemfire - IllegalStateException on cache create

我正在嘗試運行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();

線程“主”中的異常java.lang.IllegalStateException:DynamicRegionFactory的客戶端池必須配置為queue-enabled設置為true。

我不知道如何將啟用隊列設置為true。 我會喜歡一些代碼,而不是“檢查文檔的這一部分”之類的答案。 我已經到處都看過了。

您應該在池中啟用訂閱。 attribute to your pool configuration. 只需在您的池配置中添加屬性即可。

注意:您的客戶應支持交易。 最好在緩存服務器上使用動態區域。 從客戶端呼叫遠程功能。

例:

功能:

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並創建根區域。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM