EXAMPLES
ContentFilteredTopic
1) Description
The ContentFilteredTopic example is used to illustrate message filtering based upon Content-Based subscription.
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)
- ContentFilteredTopicDataSubscriber application uses Content-based subscription
- ContentFilteredTopicDataPublisher generates stock quotes for two ticker symbols, GE and MSFT.
3) Scenario
The ContentFilteredTopicDataPublisher application generates stock quotes for two ticker symbols, GE and MSFT.
In order to subscribe to a particular ticker, the subscriber application ContentFilteredTopicDataSubscriber should be run
with GE or MSFT as command line arguments.
Configurable:
- symbol: the ticker to subscribe to
symbol allows the selection of the ticker to be subscribed to:
- GE : a ticker for General Electric
- MSFT : a ticker for Microsoft
Running of examples in Standalone Mode
Usage:
ContentFilteredTopicDataSubscriber usage:
ContentFilteredTopicDataSubscriber [symbol]
ContentFilteredTopicDataPublisher usage:
ContentFilteredTopicDataPublisher
Running the examples in a Posix environment
Environment Setup
Let's call OpenSplice_install_dir the OpenSplice installation directory.
The OpenSplice 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_contentfilteredtopic_pub
- sacpp_contentfilteredtopic_sub
- libsacpp_contentfilteredtopic_types.so
For C
- sac_contentfilteredtopic_pub
- sac_contentfilteredtopic_sub
- libsac_contentfilteredtopic_types.so
Java executables
Building the examples is described on the Summary page
Three jars are generated in the java\standalone or java5 directory when the example is built:
For java
- saj_contentfilteredtopic_pub.jar
- saj_contentfilteredtopic_sub.jar
- saj_contentfilteredtopic_types.jar
For java5
- saj5_contentfilteredtopic_pub.jar
- saj5_contentfilteredtopic_sub.jar
- saj5_contentfilteredtopic_types.jar
ISO C++ 2 Executables
Building the examples is described on the Summary page
Two executables are generated in the isocpp2 directory when the example is built:
Running the example
Ensure that the environment for OpenSplice is setup correctly as described above for each new terminal used.
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 OpenSplice middleware
- OpenSplice is deployed in this mode by default.
- The OpenSplice daemon should not be started manually. Instead the OpenSplice middleware and optional services are implicitly started by the single process applications as required
- Open 2 terminals. Set up the environment and go to the example directory as described above
Running in multiple process shared memory configuration
To enable deployment in this mode, an OpenSplice 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 the example directory 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_contentfilteredtopic_sub GE for C
- sacpp_contentfilteredtopic_sub GE for C++
- java -jar saj_contentfilteredtopic_sub.jar GE for Java
- java -jar saj5_contentfilteredtopic_sub.jar GE for Java5
- subscriber GE for isocpp2
- In the second terminal start the publisher by running either
- sac_contentfilteredtopic_pub for C
- sacpp_contentfilteredtopic_pub for C++
- java -jar saj_contentfilteredtopic_pub.jar for Java
- java -jar saj5_contentfilteredtopic_pub.jar for Java5
- publisher for isocpp2
Running C/C++/C#/ISO C++ 2/Java examples on Windows
Environment Setup
Let's call OpenSplice_install_dir the OpenSplice installation directory.
The OpenSplice environment variables must be set in order for the examples to run correctly.
To do this open an OpenSplice Command Prompt which will set up the environment variables for OpenSplice automatically. The OpenSplice 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_contentfilteredtopic_sub.exe
- sac_contentfilteredtopic_pub.exe
For C++
- sacpp_contentfilteredtopic_sub.exe
- sacpp_contentfilteredtopic_pub.exe
For C#
- sacs_contentfilteredtopic_sub.exe
- sacs_contentfilteredtopic_pub.exe
Java Executables
Building the examples is described on the Summary page
Three jars are generated in the java\standalone or java5 directory when the example is built:
For java
- saj_contentfilteredtopic_pub.jar
- saj_contentfilteredtopic_sub.jar
- saj_contentfilteredtopic_types.jar
For java5
- saj5_contentfilteredtopic_pub.jar
- saj5_contentfilteredtopic_sub.jar
- saj5_contentfilteredtopic_types.jar
ISO C++ 2 Executables
Building the examples is described on the Summary page
Two executables are generated in the isocpp2 directory when the example is built:
- publisher.exe
- subscriber.exe
Running the C/C++/C#/ISO C++ 2/Java Examples
Ensure that the environment for OpenSplice is setup 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 OpenSplice middleware
- OpenSplice is deployed in this mode by default.
- The OpenSplice daemon should not be started manually. Instead the OpenSplice middleware and optional services are implicitly started by the single process applications as required
- Open 2 OpenSplice Command Prompts and go to the example directory as described above
Running in multiple process shared memory configuration
To enable deployment in this mode, an OpenSplice 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 OpenSplice Command Prompts. In each window:
- Go to the example directory as described above
- Set the required configuraton 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_contentfilteredtopic_sub GE for C
- sacpp_contentfilteredtopic_sub GE for C++
- sacs_contentfilteredtopic_sub GE for C#
- java -jar saj_contentfilteredtopic_sub.jar GE for Java
- java -jar saj5_contentfilteredtopic_sub.jar GE for Java5
- subscriber for isocpp2
- In the second terminal start the publisher by running either
- sac_contentfilteredtopic_pub for C
- sacpp_contentfilteredtopic_pub for C++
- sacs_contentfilteredtopic_pub for C#
- java -jar saj_contentfilteredtopic_pub.jar for Java
- java -jar saj5_contentfilteredtopic_pub.jar for Java5
- publisher for isocpp2