EXAMPLES
QueryCondition
1) Description
The QueryCondition example is used to illustrate message filtering through use of Queries.
2) Design
It consists of 4 units :
- CheckStatus : provides return status checking
- DDSEntityManager : implements a class providing operations to set up DCPS
entities(creation, deletion)
- QueryConditionDataPublisher application generates stock quotes for two ticker symbols, GE and MSFT.
- QueryConditionDataSubscriber filters events through use of Queries.
3) Scenario
The QueryConditionDataPublisher application generates stock quotes for two ticker symbols, GE and MSFT.
In order to subscribe to a particular ticker, the subscriber application QueryConditionDataSubscriber should be run
with GE or MSFT as command line arguments.
Running of examples in Standalone Mode
Running the examples in a Posix environment
Environment Setup
Let's call OpenSplice_install_dir the OpenSplice installation directory.
The OpenSpliceDDS environment variables must be set in order for the examples to build/run correctly.
To do this, open a terminal and source the "OpenSplice_install_dir/release.com" script supplied with the distribution.
C and C++ Executables
Building the examples is described on the Summary page
Two executables and a library are generated in the standalone directory when the example is built:
For C++
- sacpp_querycondition_pub
- sacpp_querycondition_sub
- libsacpp_querycondition_types.so
For C
- sac_querycondition_pub
- sac_querycondition_sub
- libsac_querycondition_types.so
Java executables
Building the examples is described on the Summary page
Two jars are generated in the standalone directory when the example is built:
- saj_querycondition_app.jar
- saj_querycondition.jar
Running the example
Ensure that the environment for OpenSpliceDDS is set up correctly as described above for each new terminal used. If running the C or C++ examples ensure that
. is added to the LD_LIBRARY_PATH.
It is recommended that you run the subscriber and publisher in separate terminals to avoid mixing the output
Running in single process (heap memory) configuration : the application starts OpenSpliceDDS middleware
- OpenSpliceDDS is deployed in this mode by default.
- The OpenSplice daemon should not be started manually. Instead the OpenSpliceDDS middleware and optional services are implicitly started by the single process applications as required
- Open 2 terminals. Set up the environment and go to directory standalone as described above
Running in multiple process shared memory configuration
To enable deployment in this mode, an OpenSpliceDDS configuration file must be selected that has shared memory support e.g. one of the ospl_shmem xml configuration files found in the OpenSplice_install_dir/etc/config directory.
- Open 2 terminals. In each terminal:
- Setup the environment and go to directory standalone as described above
- Set the required configuraton file e.g. OSPL_URI=file://$OSPL_HOME/etc/config/ospl_shmem_ddsi.xml
- Start the OpenSplice daemon. You can do this by typing ospl start
Starting the subscriber and publisher
- In the first terminal start the subscriber by running either
- sac_querycondition_sub GE (or MSFT) for C OR
- sacpp_querycondition_sub GE (or MSFT) for C++ OR
- java -classpath $OSPL_HOME/jar/dcpssaj.jar:classes QueryConditionDataSubscriber GE (or MSFT) for Java
- In the second terminal start the publisher by running either
- sac_querycondition_pub for C OR
- sacpp_querycondition_pub for C++ OR
- java -classpath $OSPL_HOME/jar/dcpssaj.jar:classes QueryConditionDataPublisher for Java
Running C/C++/C#/Java examples on Windows
Environment Setup
Let's call OpenSplice_install_dir the OpenSplice installation directory.
The OpenSpliceDDS environment variables must be set in order for the examples to run correctly.
To do this open an OpenSpliceDDS Command Prompt which will set up the environment variables for OpenSpliceDDS automatically. The OpenSpliceDDS Command Prompt can be selected from the start menu. Alternatively, open a windows Command Prompt and execute the "OpenSplice_install_dir\release.bat" batch script supplied with the distribution.
C/C++/C# Executables
Building the examples is described on the Summary page
Two executables are generated in the standalone directory when the example is built:
For C
- sac_querycondition_sub.exe
- sac_querycondition_pub.exe
For C++
- sacpp_querycondition_sub.exe
- sacpp_querycondition_pub.exe
Java Executables
Building the examples is described on the Summary page
The subscriber and publisher classes are generated in the standalone directory when the example is built:
- QueryConditionDataPublisher.class
- QueryConditionDataSubscriber.class
Running the C/C++/C#/Java Examples
Ensure that the environment for OpenSpliceDDS is set up correctly as described above for each new command prompt used.
The following steps describe how to run the examples:
Running in single process (heap memory) configuration : the application starts OpenSpliceDDS middleware
- OpenSpliceDDS is deployed in this mode by default.
- The OpenSplice daemon should not be started manually. Instead the OpenSpliceDDS middleware and optional services are implicitly started by the single process applications as required
- Open 2 OpenSpliceDDS Command Prompts and go to directory standalone as described above
Running in multiple process shared memory configuration
To enable deployment in this mode, an OpenSpliceDDS configuration file must be selected that has shared memory support e.g. one of the ospl_shmem xml configuration files found in the OpenSplice_install_dir\etc\config directory.
- Open 2 OpenSpliceDDS Command Prompts. In each window:
- Go to directory standalone as described above
- Set the required configuration file e.g. set OSPL_URI="file://%OSPL_HOME%\etc\config\ospl_shmem_ddsi.xml"
- Start the OpenSplice daemon. You can do this by typing ospl start
Starting the subscriber and publisher
- In the first terminal start the subscriber by running either
- sac_querycondition_sub GE (or MSFT) for C OR
- sacpp_querycondition_sub GE (or MSFT) for C++ OR
- start java -classpath "%OSPL_HOME%\jar\dcpssaj.jar";classes QueryConditionDataSubscriber GE (or MSFT) for Java
- In the second terminal start the publisher by running either
- sac_querycondition_pub for C OR
- sacpp_querycondition_pub for C++ OR
- java -classpath "%OSPL_HOME%\jar\dcpssaj.jar";classes QueryConditionDataPublisher for Java