GemFire Enterprise Native Client

C# Programming Example

About the CqQuery Example

The CqQuery example is a C# program that uses Microsoft .NET Framework 2.0 to access the GemFire C++ API for continuous query.

Microsoft .NET Framework 2.0 must be installed before running this example. For information about installing the .NET Framework, see the GemFire Enterprise Native Client Guide.

The client application comes with a cache configuration file, clientCqQuery.xml, which is configured to create a root region and establish the native client endpoints to the locally-run server by specifying localhost:50505. If java server is located on another host, change localhost to that host accordingly.

The CqQuery cache listens for client requests at a specific port (see serverCqQuery.xml). The client connects to the cache server's port.

Configuring the Environment

Examples that interact with a Java cache server require specific environment configurations so the Java cache server will run properly. Follow the configuration steps listed below that apply to your operating system:

  1. From the GemFire Enterprise product installation directory, configure your environment settings by following the steps in examples/EnvSetup.html. Refer to the developer's guide if you need help with this step.
  2. Set the JAVA_HOME and GF_JAVA_HOME environment variables to your installed Java JRE or JDK. See the Installation chapter of the GemFire Enterprise System Administrator's Guide for the versions of Java that are compatible with GemFire Enterprise. The JAVA_HOME setting is for your applications, and GF_JAVA_HOME is for the GemFire scripts. You must have a compatible Java JRE or JDK installed and you must set JAVA_HOME and GF_JAVA_HOME to point to it.
  3. Add $JAVA_HOME/bin to the start of your PATH.
  4. Add the GemFire quickstart classes to your CLASSPATH.

set CLASSPATH=%GEMFIRE%\quickstart\classes;%CLASSPATH%

The following is a list of the environment configuration commands for the CqQuery example. Choose the set of commands that are appropriate for your operating system. The text that you type is shown in bold. These configurations only need to be performed for the sessions that invoke the Java cache server.

Bourne and Korn shells (sh, ksh, bash)

% cd GemFireInstallDirectory
% CLASSPATH=$CLASSPATH:$GEMFIRE/quickstart/classes; export CLASSPATH
% cd $GEMFIRE/quickstart
% JAVA_HOME=<Installed JRE PATH>; export JAVA_HOME
% PATH=$JAVA_HOME/bin:$PATH; export PATH


> cd GemFireInstallDirectory
> set CLASSPATH=%GEMFIRE%\quickstart\classes;%CLASSPATH%
> cd %GEMFIRE%\quickstart
> set JAVA_HOME=<Installed JRE PATH>
> set PATH=%JAVA_HOME%\bin;%PATH%

Starting CqQuery

To run the CqQuery example, create a session from the GemFire Enterprise product directory and complete the following steps. Throughout this example, when you're prompted to enter the native client directory, replace the xxxx in NativeClient_xxxx with the actual four-digit product version number. Note that in the following steps, except CqQuery.exe, all other programs can be run on other operating system machines.

This first session starts the Java cache server.

    cd \NativeClient_xxxx\examples\cqQuery

  1. start java server:


  1. Create another session and go to the cli_CqQuery example directory:

cd \NativeClient_xxxx\examples\cli_CqQuery

  1. Start the CqQuery application:


  1. Start the updater application:

In another window,

cd \NativeClient_xxxx\examples\cqQuery

   runUpdater.bat <itr number>, where itr number is the number of iterations you want this program to run, e.g, 500.

  1. Stop Java:

In the window where java server was started:



Copyright © 2005-0109 by GemStone Systems, Inc. All rights reserved. GemStone®, GemFire®, and the GemStone logo are trademarks or registered trademarks of GemStone Systems, Inc. All other trade names or trademarks are the property of their respective owners. Information in this document is subject to change without notice.