org.apache.geode.cache.query

## Interface CqQuery

-     public interface CqQuery

  Interface for continuous query. This provides methods for managing a CQ once it is created through the QueryService. The methods allow you to retrieve CQ related information, operate on CQ like execute, stop, close and get the state of the CQ.
  Since:
    GemFire 5.5

- - ### Method Summary

    All Methods Instance Methods Abstract Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `close()` Close the CQ and stop execution.
    `void` | `execute()` Start executing the CQ or if this CQ is stopped earlier, resumes execution of the CQ.
    `<E> CqResults<E>` | `executeWithInitialResults()` Starts executing the CQ or, if the CQ is in a stopped state, resumes execution.
    `CqAttributes` | `getCqAttributes()` Get CqAttributes for this CQ.
    `CqAttributesMutator` | `getCqAttributesMutator()` Get CqAttributesMutator for this CQ.
    `java.lang.String` | `getName()` Get the name of the CQ.
    `Query` | `getQuery()` Get the query object generated for this CQs query.
    `java.lang.String` | `getQueryString()` Get the original query string that was specified with CQ.
    `CqState` | `getState()` Get the state of the CQ in CqState object form.
    `CqStatistics` | `getStatistics()` Get statistics information for this CQ.
    `boolean` | `isClosed()` This allows to check if the CQ is closed.
    `boolean` | `isDurable()` This allows to check if the CQ is durable.
    `boolean` | `isRunning()` This allows to check if the CQ is in running or active.
    `boolean` | `isStopped()` This allows to check if the CQ is in stopped.
    `void` | `stop()` Stops this CqQuery without releasing resources.

- - ### Method Detail

    - #### getQueryString

          java.lang.String getQueryString()

      Get the original query string that was specified with CQ.
      Returns:
        String the query string associated with CQ.

    - #### getQuery

          Query getQuery()

      Get the query object generated for this CQs query.
      Returns:
        Query query object for the query string.

    - #### getName

          java.lang.String getName()

      Get the name of the CQ.
      Returns:
        the name of the CQ.

    - #### getStatistics

          CqStatistics getStatistics()

      Get statistics information for this CQ.
      Returns:
        CqStatistics CQ statistics object.

    - #### getCqAttributes

          CqAttributes getCqAttributes()

      Get CqAttributes for this CQ.
      Returns:
        CqAttributes cqAttribute set with this CqQuery.
      See Also:
        `CqAttributes`

    - #### getCqAttributesMutator

          CqAttributesMutator getCqAttributesMutator()

      Get CqAttributesMutator for this CQ.
      Returns:
        CqAttributesMutator.
      See Also:
        `CqAttributesMutator`

    - #### executeWithInitialResults

          <E> CqResults<E> executeWithInitialResults()
                                              throws CqClosedException,
                                                     RegionNotFoundException,
                                                     CqException

      Starts executing the CQ or, if the CQ is in a stopped state, resumes execution. Gets the current resultset for the CQ query. The CQ is executed on the primary server, and then redundant servers as needed. If execution fails on all servers, a CqException is thrown. If the query is complex and the data set is large, this execution may take a long time, which may cause a socket read timeout in the client. To allow adequate time, you may need to set a longer pool read-timeout in the client.
      Returns:
        SelectResults resultset obtained by executing the query.
      Throws:
        `CqClosedException` - if this CqQuery is closed.
        `RegionNotFoundException` - if the specified region in the query string is not found.
        `java.lang.IllegalStateException` - if the CqQuery is in the RUNNING state already.
        `CqException` - if failed to execute and get initial results.

    - #### execute

          void execute()
                throws CqClosedException,
                       RegionNotFoundException,
                       CqException

      Start executing the CQ or if this CQ is stopped earlier, resumes execution of the CQ. The CQ is executed on primary and redundant servers, if CQ execution fails on all the server then a CqException is thrown.
      Throws:
        `CqClosedException` - if this CqQuery is closed.
        `RegionNotFoundException` - if the specified region in the query string is not found.
        `java.lang.IllegalStateException` - if the CqQuery is in the RUNNING state already.
        `CqException` - if failed to execute.

    - #### stop

          void stop()
             throws CqClosedException,
                    CqException

      Stops this CqQuery without releasing resources. Puts the CqQuery into the STOPPED state. Can be resumed by calling execute or executeWithInitialResults.
      Throws:
        `java.lang.IllegalStateException` - if the CqQuery is in the STOPPED state already.
        `CqClosedException` - if the CQ is CLOSED.
        `CqException`

    - #### getState

          CqState getState()

      Get the state of the CQ in CqState object form. CqState supports methods like isClosed(), isRunning(), isStopped().
      Returns:
        CqState state object of the CQ.
      See Also:
        `CqState`

    - #### close

          void close()
              throws CqClosedException,
                     CqException

      Close the CQ and stop execution. Releases the resources associated with this CqQuery.
      Throws:
        `CqClosedException` - Further calls on this CqQuery instance except for getState() or getName().
        `CqException` - - if failure during cleanup of CQ resources.

    - #### isRunning

          boolean isRunning()

      This allows to check if the CQ is in running or active.
      Returns:
        boolean true if running, false otherwise

    - #### isStopped

          boolean isStopped()

      This allows to check if the CQ is in stopped.
      Returns:
        boolean true if stopped, false otherwise

    - #### isClosed

          boolean isClosed()

      This allows to check if the CQ is closed.
      Returns:
        boolean true if closed, false otherwise

    - #### isDurable

          boolean isDurable()

      This allows to check if the CQ is durable.
      Returns:
        boolean true if durable, false otherwise
      Since:
        GemFire 5.5