Unable to create Continuous Query on geode

 ̄綄美尐妖づ 提交于 2020-01-07 02:59:05

问题


I am trying to do a poc on creating continiuous query on Apache Geode. But Getting below exception

Caused by: java.lang.IllegalStateException: CqService is not available.
    at com.gemstone.gemfire.cache.query.internal.cq.MissingCqService.start(MissingCqService.java:171) ~[gemfire-core-1.0.0-incubating.M1.jar:na]
    at com.gemstone.gemfire.cache.query.internal.DefaultQueryService.getCqService(DefaultQueryService.java:810) ~[gemfire-core-1.0.0-incubating.M1.jar:na]
    at com.gemstone.gemfire.cache.query.internal.DefaultQueryService.newCq(DefaultQueryService.java:595) ~[gemfire-core-1.0.0-incubating.M1.jar:na]
    at com.gemfirepo.GedoeConfiguration.getQueryService(GedoeConfiguration.java:79) ~[classes/:na]
    at com.gemfirepo.GedoeConfiguration$$EnhancerBySpringCGLIB$$9bd68b16.CGLIB$getQueryService$1(<generated>) ~[classes/:na]
    at com.gemfirepo.GedoeConfiguration$$EnhancerBySpringCGLIB$$9bd68b16$$FastClassBySpringCGLIB$$5b2bc172.invoke(<generated>) ~[classes/:na]
    at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228) ~[spring-core-4.2.7.RELEASE.jar:4.2.7.RELEASE]
    at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:356) ~[spring-context-4.2.7.RELEASE.jar:4.2.7.RELEASE]
    at com.gemfirepo.GedoeConfiguration$$EnhancerBySpringCGLIB$$9bd68b16.getQueryService(<generated>) ~[classes/:na]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_45]
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_45]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_45]
    at java.lang.reflect.Method.invoke(Method.java:497) ~[na:1.8.0_45]

I have created my region using

create region --name=Student --type=REPLICATE --enable-statistic=true --enable-subscription-conflation=true

Please find below code i am using for creating QueryService and registering for CQ

    @Bean 
    QueryService getQueryService() throws CqException, QueryInvalidException, CqExistsException, CqClosedException, RegionNotFoundException{
          ClientCache cache =appContext.getBean(ClientCache.class);

          QueryService qservice= cache.getQueryService();

          CqAttributesFactory cqf = new CqAttributesFactory();
          cqf.addCqListener(new CqListener() {

            @Override
            public void close() {
                // TODO Auto-generated method stub

            }

            @Override
            public void onEvent(CqEvent aCqEvent) {
                // TODO Auto-generated method stub
                System.out.println("Event Recieved !");
            }

            @Override
            public void onError(CqEvent aCqEvent) {
                // TODO Auto-generated method stub

            }
        });
          CqQuery studentTracker=qservice.newCq("StudentQuery","SELECT name from /Student where rollNo==0",cqf.create());

//        qservice.executeCqs("/Student");
          studentTracker.execute();
//        System.out.println(qservice.getCqStatistics().numCqsActive()+" *****************");
          studentTracker.close();
          return qservice;
    }

It will be a great help if someone can share working example for Gemfire Continuous Query


回答1:


I got answer for above problem from Geode user list . I was using wrong version of Geode the Continuous Query feature is supported after M2 Release



来源:https://stackoverflow.com/questions/38563332/unable-to-create-continuous-query-on-geode

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!