Uploaded image for project: 'Geode'
  1. Geode
  2. GEODE-1913

Calling the CQ API without the geode-cq module loaded should give a more descriptive exception

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Open
    • Major
    • Resolution: Unresolved
    • None
    • None
    • querying
    • None

    Description

      The interfaces for continuous query functionality (CqEvent, CqListener, etc) reside in the geode-core module but their implementations reside in the geode-cq module. This results in a non-descriptive exception if CQs are invoked from an application which has loaded geode-core but not geode-cq.
      For example,

      ClientCache cache = new ClientCacheFactory()
                      .addPoolLocator("localhost", 10334)
                      .setPoolSubscriptionEnabled(true)
                      .create();
      
        Region<String, BigDecimal> region = cache
                      .<String, BigDecimal>createClientRegionFactory(ClientRegionShortcut.CACHING_PROXY)
                      .create("regionA");
      
        CqAttributesFactory cqf = new CqAttributesFactory();
              cqf.addCqListener(new ExampleContinuousQueryListener());
              CqAttributes cqa = cqf.create();
      
        QueryService queryService = region.getRegionService().getQueryService();
              CqQuery priceTracker = queryService.newCq(cqName, queryStr, cqa);
      

      gives the following exception:

      Exception in thread "main" java.lang.IllegalStateException: CqService is not available.
          at com.gemstone.gemfire.cache.query.internal.cq.MissingCqService.start(MissingCqService.java:171)
          at com.gemstone.gemfire.cache.query.internal.DefaultQueryService.getCqService(DefaultQueryService.java:777)
          at com.gemstone.gemfire.cache.query.internal.DefaultQueryService.newCq(DefaultQueryService.java:562)
          at com.jaredjstewart.HelloWorld.main(HelloWorld.java:40)
          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
          at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
          at java.lang.reflect.Method.invoke(Method.java:498)
          at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147)
      

      It would be helpful to check whether the geode-cq module is available on the classpath before throwing this exception so that we could give the user a more explanatory message in the stack trace like "Continuous query functionality relies on the geode-cq module being loaded".

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              jstewart Jared Stewart
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated: