Publish/Subscribe DDS Stock Quoter Service (Assignment 1)

Overview

In this assignment, you will implement a simple Stock Quoter application using the Data Distribution Service (DDS). Publishers anonymously publish data that has been updated and subscribers can anonymously receive data that a publisher publishes. In this application, DDS subscribers are used to subscribe to a current stock quote from a publisher anonymously in a network.

DDS IDL Specification

The DDS Stock Quoter application will be designed as a publisher/subscriber pair using the following IDL specification:

// The #pragma is specific to OpenDDS
#pragma DCPS_DATA_TYPE "Quote"

struct Quote {
    double price;
    string symbol;
    string full_name;
};
You will use the mwc.pl Perl script on the file Quoter.mpc (which uses the Quoter.idl file) to generate the needed support code and makefiles for the publisher and subscriber executables. This script is located in $ACE_ROOT/bin. For Linux, the command line might look something like this:

$ $ACE_ROOT/bin/mwc.pl -type gnuace
For Visual Studio 2005, the command line might look something like this:

C:\> %ACE_ROOT%\bin\mwc.pl -type vc8
The makefiles or solution files should then be ready for you to use.

The publisher executable (whose source code you must modify) will update values to the stocks. The subscriber application (whose source code you also must modify) will then output updates when they are received.

You will be given boilerplate code for the parts that are not generated for you by the mpc.pl script. This is described in more detail below. You can download all of this code in a single zip file from here.

Subscriber Functionality

First, make sure that the mpc.pl script has been run on the Quoter.mpc file to generate the needed support code and makefiles.

When the subscriber starts up, it will wait for data updates and manipulate the data when it arrives (e.g., display it to the screen). On the subscriber side, you'll need to modify the boilerplate code supplied in subscriber.cpp and DataReaderListener.cpp to make the appropriate DDS calls. You will also need the file DataReaderListener.h as well but you shouldn't need to modify it.

In particular, you will need to modify subscriber.cpp to:

Additionally, you will need to implement the appropriate DataReaderListener method(s) (in DataReaderListener.cpp) to: There are sections of the source files provided that are bracketed by "// To Do: " and "// End: " blocks. These sections are where code should be added.

The subscriber executable takes 2 command line arguments: one to set up the transport (i.e., -ORBSvcConf tcp.conf) and one to set up the subscriber (i.e., -DCPSConfigFile sub.ini). You will not need to modify these files. Here are the tcp.conf and sub.ini files.

If anything fails to work properly the subscriber should simply print out the appropriate exception and exit with a return status of 1. If everything works correctly, the program should exit with a return status of 0.

Publisher Functionality

As noted above, make sure that the mpc.pl script has been run on the Quoter.mpc file to generate the needed support code and makefiles.

When the publisher starts up, it will update and publish stock prices. On the publisher side, you'll need to modify the boilerplate code supplied in publisher.cpp and Writer.cpp to make the appropriate DDS calls. You will also need the file Writer.h as well but you shouldn't need to modify it.

In particular, you will need to modify publisher.cpp to:

Additionally, you will need to implement the Writer's svc method (in Writer.cpp) to: There are sections of the source files provided that are bracketed by "// To Do: " and "// End: " blocks. These sections are where code should be added.

The publisher executable takes 2 command line arguments: one to set up the transport (i.e., -ORBSvcConf tcp.conf) and one to set up the publisher (i.e., -DCPSConfigFile pub.ini). You will not need to modify these files. Here are the tcp.conf and pub.ini files.

If anything fails to work properly the publisher should simply print out the appropriate exception and exit with a return status of 1. If everything works correctly, the program should exit with a return status of 0.


Running OpenDDS Applications

For this assignment, it is assumed that all applicable executables (i.e., the publisher, the subscriber, and the information repository) are run from the same NFS-enabled directory. There is a common file that is shared between the executables and launching from the same directory simplifies the sharing of this file.

Also, the order in which the executables are invoked in important. The Info Repository needs to be launched first, then the subscriber, then the publisher.

OpenDDS' Info Repository

The OpenDDS implementation uses an information repository to keep track of various information related to DDS participants. The Info Repository is a separate executable that must be started before all the other executables are launched. Here is the domain_ids file to use.

The Info Repository should be launched as follows:


$DDS_ROOT/dds/InfoRepo/DCPSInfoRepo -ORBSvcConf tcp.conf -o repo.ior -d domain_ids
where DDS_ROOT is equivalent to $ACE_wrappers/TAO/DDS.

It also needs to be manually killed when the DDS application is done running. There will be a file named repo.ior left in the directory. It is a good idea to delete this file to avoid any confusion for succeeding invocations (although there may be no harm in leaving it alone).

Example Output

The following output is an example of what your output might look like.

Example output for the Info Repository:


$ $DDS_ROOT/dds/InfoRepo/DCPSInfoRepo -ORBSvcConf tcp.conf -o repo.ior -d domain_ids
(12588|3078248128)  13:55:01.262144 Repo main
(12588|3078248128)INFO: not using file configuration - no configuration file specified.

Example output for the supplier:


$ ./subscriber -ORBSvcConf tcp.conf -DCPSConfigFile sub.ini
DataReaderListenerImpl::on_subscription_match
Quoter: price     = 100
        symbol    = IBM
        full name = International Business Machines
Quoter: price     = 10
        symbol    = MSFT
        full name = Microsoft Corporation
Quoter: price     = 200
        symbol    = IBM
        full name = International Business Machines
Quoter: price     = 20
        symbol    = MSFT
        full name = Microsoft Corporation
Quoter: price     = 300
        symbol    = IBM
        full name = International Business Machines
Quoter: price     = 30
        symbol    = MSFT
        full name = Microsoft Corporation
Quoter: price     = 400
        symbol    = IBM
        full name = International Business Machines
Quoter: price     = 40
        symbol    = MSFT
        full name = Microsoft Corporation
Quoter: price     = 500
        symbol    = IBM
        full name = International Business Machines
Quoter: price     = 50
        symbol    = MSFT
        full name = Microsoft Corporation
Quoter: price     = 600
        symbol    = IBM
        full name = International Business Machines
Quoter: price     = 60
        symbol    = MSFT
        full name = Microsoft Corporation
Quoter: price     = 700
        symbol    = IBM
        full name = International Business Machines
Quoter: price     = 70
        symbol    = MSFT
        full name = Microsoft Corporation
Quoter: price     = 800
        symbol    = IBM
        full name = International Business Machines
Quoter: price     = 80
        symbol    = MSFT
        full name = Microsoft Corporation
Quoter: price     = 900
        symbol    = IBM
        full name = International Business Machines
Quoter: price     = 90
        symbol    = MSFT
        full name = Microsoft Corporation
Quoter: price     = 1000
        symbol    = IBM
        full name = International Business Machines
Quoter: price     = 100
        symbol    = MSFT
        full name = Microsoft Corporation
Example output for the publisher:


$ ./publisher -ORBSvcConf tcp.conf -DCPSConfigFile pub.ini
(20553|3086640832) Writer::start
(20553|3027631024) Writer::svc begins.
 13:55:31.995447 (20553|3027631024) Writer::svc starting to write.
(20553|3027631024) Writer::svc finished.
(20553|3086640832) Writer::end

Learning and Using DDS

You will be using the OpenDDS Data Distribution Service (DDS) implementation. Please reference the documentation there for downloading and setting up OpenDDS.

You will also need to download and install ACE and TAO. Please see the online documentation for information on how to setup your ACE and TAO development environment on EECS's computing system.

NOTE: There is also an example OpenDDS application in the OpenDDS distribution under $DDS_ROOT/DevGuideExamples/DCPS/Messenger. This example should be helpful if you're stuck on what OpenDDS calls to make in your code.


Concluding Remarks

This first DDS assignment should fairly straightforward. However, it will illustrate the basic skills required to become adept at using DDS publish/subscribe middleware to developed distributed applications. Subsequent assignments will build on this assignment, so make sure you get it working correctly.


Back to CS 395-2 home page.