int main (int argc, const char** argv)
{
    try
    {
        CommonCommandLineParser     cmdLine (argc, argv);
        // Initialise the MAMA API
        mamaBridge bridge = Mama::loadBridge (cmdLine.getMiddleware());
        Mama::open ();
               
        const vector<const char*>&
                         symbolList        = cmdLine.getSymbolList ();
        MamaSource*      source            = cmdLine.getSource();
        MamaQueueGroup   queues (cmdLine.getNumThreads(), bridge);
        DictRequester    dictRequester (bridge);
        uint32_t         intervalSecs      = cmdLine.getOptInt('i');

        if (intervalSecs == 0)
            intervalSecs = 5;

        // We might as well also enforce strict checking of order book updates.
        MamdaOrderBook::setStrictChecking (true);

        // Get and initialize the dictionary
        dictRequester.requestDictionary (cmdLine.getDictSource());
        MamdaOrderBookFields::setDictionary (*dictRequester.getDictionary());

        for (vector<const char*>::const_iterator i = symbolList.begin();
            i != symbolList.end();
            ++i)
        {
            const char* symbol = *i;
            BookSelfTest* aSelfTest = new BookSelfTest;
            MamdaOrderBookChecker*  aBookChecker  =
                new MamdaOrderBookChecker (queues.getNextQueue(), aSelfTest,
                                           source, symbol, intervalSecs);
        }
        Mama::start(bridge);
    }
    catch (MamaStatus &e)
    {  
        // This exception can be thrown from Mama.open ()
        // Mama::createTransport (transportName) and from
        // MamdaSubscription constructor when entitlements is enabled.
        cerr << "MamaStatus exception in main (): " << e.toString () << endl;
        exit (1);
    }
    catch (exception &ex)
    {
        cerr << "Exception in main (): " << ex.what () << endl;
        exit (1);
    }
    catch (...)
    {
        cerr << "Unknown Exception in main ()." << endl;
        exit (1);
    }

    return 1;
}
void BookPublisher::createPublisherManager (const char* pubSource, mamaBridge bridge)
{
    mPublisherManager = new MamaDQPublisherManager();

    //create pub
    mPublisherManager->create (mPubTransport, 
                         mQueueGroup->getNextQueue(),
                         this,
                         pubSource);
}
Example #3
0
void MamaPublisherSample::run()
{
    try
    {
        mBridge = Mama::loadBridge (gMiddleware);

        Mama::open ();

        mDefaultQueue = Mama::getDefaultEventQueue (mBridge);

        mMsg = new MamaMsg();
        mMsg->create();

        mTransport = new MamaTransport();
        mTransport->create (gTransportName, mBridge);

        mTimer = new MamaTimer();
        mTimer->create (mDefaultQueue, this, gInterval);

        mQueueGroup = new MamaQueueGroup(1, mBridge);

        mSubscription = new MamaBasicSubscription();
        mSubscription->createBasic (mTransport,
                                    mDefaultQueue,
                                    this,
                                    gInBoundTopic);

        mPublisher = new MamaPublisher();
        if (gPubCb)
        {
            mPublisher->createWithCallbacks (mTransport,
                                             mQueueGroup->getNextQueue(),
                                             this,
                                             NULL,
                                             gOutBoundTopic,
                                             gSource,
                                             NULL);
        }
        else
        {
            mPublisher->create (mTransport, gOutBoundTopic);
        }
    }
    catch (MamaStatus &status)
    {
        cerr << "Caught MAMA exception: " << status.toString () << endl;
        exit (1);
    }

    Mama::start (mBridge);

    Mama::close ();
}
void MamaEntitle::subscribeToSymbol (const char* symbol)
{
    static int howMany = 0;

    if (!mDisplayCallback)
    {
        mDisplayCallback = new DisplayCallback (this);
    }
    
    MamaSubscription* sub = NULL;
    sub = new MamaSubscription;
    
    sub->setRetries (3);
    sub->setRequiresInitial (mRequireInitial);
        
    if (mSnapshot)
    {
        sub->setSubscriptionType (MAMA_SUBSC_TYPE_NORMAL);
        sub->setServiceLevel (MAMA_SERVICE_LEVEL_SNAPSHOT, 0);
    }
    else if (mGroupSubscription)
    {
        sub->setSubscriptionType (MAMA_SUBSC_TYPE_GROUP);
        sub->setServiceLevel (MAMA_SERVICE_LEVEL_REAL_TIME, 0);
    }
    else
    {
        sub->setSubscriptionType (MAMA_SUBSC_TYPE_NORMAL);
        sub->setServiceLevel (MAMA_SERVICE_LEVEL_REAL_TIME, 0);
    }
    
    sub->create (
        mTransport,
        mQueueGroup->getNextQueue (),
        (DisplayCallback*)mDisplayCallback,
        mSource,
        symbol,
        NULL);
    
    mSubscriptionList.push_back (sub);

    if (++howMany % 1000 == 0)
    {
        printf ("Subscribed to %d subjects.\n", howMany);
    }
}
void MamaEntitle::shutdown ()
{
    if (mQueueGroup != NULL)
    {
        mQueueGroup->stopDispatch();
    }
    if (mDictionary != NULL)
    {
        delete mDictionary;
        mDictionary = NULL;
    }
        
    SubscriptionList::const_iterator i;
    
    for (i = mSubscriptionList.begin (); i != mSubscriptionList.end (); i++)
    {
        ((MamaSubscription*)*i)->destroy();
        delete *i;
    }
    
    if (mQueueGroup != NULL)
    {
        delete mQueueGroup;
        mQueueGroup = NULL;
    }
    
    if ((mDictTransport !=  NULL)  && (mDictTransport  != mTransport))                 
    {
        delete mDictTransport;
        mDictTransport = NULL;
    }
    
    if (mTransport != NULL)
    {
        delete mTransport;
        mTransport = NULL;
    }

    Mama::close ();
}
void MamaSymbolListSubscriber::subscribeToSymbols ()
{
    mQueueGroup           = new MamaQueueGroup (mThreads, mBridgeImpl);
    mSubscriptionCallback = new SubscriptionCallback (this);

    vector<string>::iterator i;
    for (i=mSubjectList.begin(); i != mSubjectList.end(); i++)
    {
        MamaSubscription* sub = NULL;
        sub = new MamaSubscription;
        string symbol = *(i);

        sub->create (mTransport,
                     mQueueGroup->getNextQueue (),
                     (SubscriptionCallback*)mSubscriptionCallback,
                     mSourceName,
                     symbol.c_str(),
                     NULL);

        mSubscriptionList.push_back (sub);
    }
}
int main (int argc, const char **argv)
{
    try
    {
        CommonCommandLineParser     cmdLine (argc, argv);
        // Initialise the MAMA API
        mamaBridge bridge = cmdLine.getBridge();
        Mama::open ();
        const vector<const char*>&  symbolList = cmdLine.getSymbolList ();
        MamaSource*                 source     = cmdLine.getSource();
        MamaQueueGroup   queues (cmdLine.getNumThreads(), bridge);
        DictRequester    dictRequester (bridge);
        dictRequester.requestDictionary (cmdLine.getDictSource());

        MamdaOrderImbalanceFields::setDictionary (*dictRequester.getDictionary ());
        MamdaCommonFields::setDictionary (*dictRequester.getDictionary());
        
        const char* symbolMapFile = cmdLine.getSymbolMapFile ();
        if (symbolMapFile)
        {
            MamaSymbolMapFile* aMap = new MamaSymbolMapFile;
            if (MAMA_STATUS_OK == aMap->load (symbolMapFile))
            {
                source->getTransport()->setSymbolMap (aMap);
            }
        }

        for (vector<const char*>::const_iterator i = symbolList.begin ();
            i != symbolList.end ();
            ++i)
        {
            const char* symbol = *i;
            MamdaSubscription* aSubscription = new MamdaSubscription;
            MamdaOrderImbalanceListener* aListener = new MamdaOrderImbalanceListener();
            OrderImbalanceTicker* aTicker = new OrderImbalanceTicker();
            
            aListener->addHandler (aTicker);
            aSubscription->addMsgListener   (aListener);
            aSubscription->addQualityListener (aTicker);
            aSubscription->addErrorListener (aTicker);
            aSubscription->create (queues.getNextQueue(), source, symbol);   
        }

        Mama::start(bridge);
    }
    catch (MamaStatus &e)
    {
        // This exception can be thrown from Mama.open (),
        // Mama::createTransport (transportName) and from
        // MamdaSubscription constructor when entitlements is enabled.
        cerr << "Exception in main (): " << e.toString () << endl;
        exit (1);
    }
    catch (exception &ex)
    {
        cerr << "Exception in main (): " << ex.what () << endl;
        exit (1);
    }
    catch (...)
    {
        cerr << "Unknown Exception in main ()." << endl;
        exit (1);
    }
}
Example #8
0
int main (int argc, const char **argv)
{
    setbuf (stdout, NULL);
    try
    {
        CommonCommandLineParser     cmdLine (argc, argv);
        // Initialize the MAMA API
        mamaBridge bridge = cmdLine.getBridge();
        Mama::open ();

        const vector<const char*>&  symbolList    = cmdLine.getSymbolList ();
        MamaSource*                 source        = cmdLine.getSource();
        MamaQueueGroup              queues (cmdLine.getNumThreads(), bridge);
        DictRequester               dictRequester (bridge);

        // We might as well enforce strict checking of order book updates
        // (at the expense of some performance).
        MamdaOrderBook::setStrictChecking (true);

        signal (SIGINT, finish);         /* arrange interrupts to terminate */
        bool useColor = !cmdLine.getOptBool ('b');  /* check for blk & white */
        start (useColor);

        // Get and initialize the dictionary
        dictRequester.requestDictionary     (cmdLine.getDictSource());
        MamdaCommonFields::setDictionary    (*dictRequester.getDictionary ());
        MamdaOrderBookFields::setDictionary (*dictRequester.getDictionary ());

        const char* symbolMapFile = cmdLine.getSymbolMapFile ();
        if (symbolMapFile)
        {
            MamaSymbolMapFile* aMap = new MamaSymbolMapFile;
            if (MAMA_STATUS_OK == aMap->load (symbolMapFile))
            {
                source->getTransport()->setSymbolMap (aMap);
            }
        }

        for (vector<const char*>::const_iterator i = symbolList.begin ();
             i != symbolList.end ();
             ++i)
        {
            const char* symbol = *i;
            MamdaSubscription*      aSubscription = new MamdaSubscription;
            MamdaOrderBookListener* aBookListener = new MamdaOrderBookListener;
            BookViewer* aViewer = 
                new BookViewer (*aBookListener->getOrderBook());

            aBookListener->setProcessEntries  (true);
            aBookListener->addHandler         (aViewer);
            aSubscription->addMsgListener     (aBookListener);
            aSubscription->addQualityListener (aViewer);
            aSubscription->addErrorListener   (aViewer);
            aSubscription->setType            (MAMA_SUBSC_TYPE_BOOK);
            aSubscription->setMdDataType      (MAMA_MD_DATA_TYPE_ORDER_BOOK);
            aSubscription->create             (queues.getNextQueue (),
                                               source,
                                               symbol);

            aViewer->setShowEntries (false);

            (new MamaIo ())->create (queues.getNextQueue (),
                                aViewer,
                                0,  /* stdin */
                                MAMA_IO_READ);
        }

        Mama::start (bridge);
    }
    catch (MamaStatus &e)
    {
        /*
           This exception can be thrown from Mama::start ().
           Mama::createTransport (transportName) and from
           MamdaSubscription constructor when entitlements is enabled.
        */
        cerr << "MamaStatus exception in main (): " << e.toString () << endl;
        exit (1);
    }
    catch (std::exception &ex)
    {
        cerr << "Exception in main (): " << ex.what () << endl;
        exit (1);
    }
    catch (...)
    {
        cerr << "Unknown Exception in main ()." << endl;
        exit (1);
    }

    return 1;
}
int main (int argc, const char **argv)
{
    try
    {
        CommonCommandLineParser  cmdLine (argc, argv);
        setvbuf (stdout, (char *) NULL, _IONBF, 0);
        // Initialise the MAMA API
        mamaBridge bridge = cmdLine.getBridge();
        Mama::open ();

        const vector<const char*>&
                         symbolList          = cmdLine.getSymbolList ();
        double           throttleRate        = cmdLine.getThrottleRate ();
        int              snapshotInterval    = cmdLine.getOptInt    ("snapshot");
        int              precision           = cmdLine.getPrecision ();
        bool             processEntries      = cmdLine.getOptBool   ('e');
        bool             strictChecking      = !cmdLine.getOptBool  ('C');
        bool             processMarketOrders = cmdLine.getOptBool   ('k');
        bool             showDeltas          = cmdLine.showDeltas   ();
        const char*      dictFile            = cmdLine.getOptString("use_dict_file");
        MamaSource*      source              = cmdLine.getSource    ();
        MamaQueueGroup   queues (cmdLine.getNumThreads(), bridge);
        DictRequester    dictRequester (bridge);

        // We might as well enforce strict checking of order book updates
        // (at the expense of some performance).
        if (strictChecking)
        {
            cout << "MamdaOrderBook strict checking is on" << endl;
            MamdaOrderBook::setStrictChecking (true);
        }
        else
        {
            cout << "MamdaOrderBook strict checking is off" << endl;
            MamdaOrderBook::setStrictChecking (false);
        }

        // Get and initialize the dictionary
        if(dictFile)
        {
            MamaDictionary* dict =new MamaDictionary;
            dict->populateFromFile(dictFile);
            MamdaCommonFields::setDictionary    (*dict);
            MamdaOrderBookFields::setDictionary (*dict);
        }
        else
        {
            dictRequester.requestDictionary     (cmdLine.getDictSource());
            MamdaCommonFields::setDictionary    (*dictRequester.getDictionary());
            MamdaOrderBookFields::setDictionary (*dictRequester.getDictionary ());
        }
        const char* symbolMapFile = cmdLine.getSymbolMapFile ();
        if (symbolMapFile)
        {
            MamaSymbolMapFile* aMap = new MamaSymbolMapFile;
            if (MAMA_STATUS_OK == aMap->load (symbolMapFile))
            {
                source->getTransport()->setSymbolMap (aMap);
            }
        }
        
        for (vector<const char*>::const_iterator i = symbolList.begin ();
            i != symbolList.end ();
            ++i)
        {
            const char* symbol = *i;
            MamdaSubscription*      aSubscription = new MamdaSubscription;
            MamdaOrderBookListener* aBookListener = new MamdaOrderBookListener;
            aSubscription->addMsgListener         (aBookListener);
            aBookListener->setProcessMarketOrders (processMarketOrders);
            aBookListener->setProcessEntries      (processEntries);

            BookTicker* aTicker = new BookTicker;

            aBookListener->addHandler         (aTicker);
            aSubscription->addQualityListener (aTicker);
            aSubscription->addErrorListener   (aTicker);

            aTicker->setShowEntries      (processEntries);
            aTicker->setShowMarketOrders (processMarketOrders);
            aTicker->setShowDeltas       (showDeltas);
            aTicker->setPrecision        (precision);
            
            aSubscription->setType (MAMA_SUBSC_TYPE_BOOK);
            aSubscription->setMdDataType (MAMA_MD_DATA_TYPE_ORDER_BOOK);
            
            aSubscription->create (queues.getNextQueue(), source, symbol);
        }

        Mama::start (bridge);
    }
    catch (MamaStatus &e)
    {  
        // This exception can be thrown from Mama.open ()
        // Mama::createTransport (transportName) and from
        // MamdaSubscription constructor when entitlements is enabled.
        cerr << "MamaStatus exception in main (): " << e.toString () << endl;
        exit (1);
    }
    catch (std::exception &ex)
    {
        cerr << "Exception in main (): " << ex.what () << endl;
        exit (1);
    }
    catch (...)
    {
        cerr << "Unknown Exception in main ()." << endl;
        exit (1);
    }

    exit (1);
}
void BookPublisher::createTimer (const char* symbol, mamaBridge bridge)
{
    //create timer, on next queue, for editing book and publishing changes every 1s
    mTimer = new MamaTimer();
    mTimer->create (mQueueGroup->getNextQueue(), this, 1);
}
Example #11
0
int main (int argc, const char** argv)
{
    MamaQueueGroup*             queues = NULL;
    mamaBridge                  bridge = NULL;
    setbuf (stdout, NULL);
    try
    {
        // Initialize the MAMA API
        CommonCommandLineParser  cmdLine (argc, argv);
        bridge = cmdLine.getBridge();
        Mama::open ();
        DictRequester               dictRequester (bridge);
        const vector<const char*>&  symbolList    = cmdLine.getSymbolList ();
        int                         threads       = cmdLine.getNumThreads ();
        MamaSource*                 source        = cmdLine.getSource();
        bool             			processMarketOrders = cmdLine.getOptBool ('k');

        queues = new MamaQueueGroup (threads, bridge);

        dictRequester.requestDictionary     (cmdLine.getDictSource());
        MamdaCommonFields::setDictionary    (*dictRequester.getDictionary ());
        MamdaTradeFields::setDictionary     (*dictRequester.getDictionary ());
        MamdaQuoteFields::setDictionary     (*dictRequester.getDictionary ());
        MamdaOrderBookFields::setDictionary (*dictRequester.getDictionary ());

        const char* symbolMapFile = cmdLine.getSymbolMapFile ();
        if (symbolMapFile)
        {
            MamaSymbolMapFile* aMap = new MamaSymbolMapFile;
            if (MAMA_STATUS_OK == aMap->load (symbolMapFile))
            {
                source->getTransport()->setSymbolMap (aMap);
            }
        }

        bool showEntries      = cmdLine.getOptBool ('e');
        bool showMarketOrders = cmdLine.getOptBool ('k');
        int  precision = cmdLine.getPrecision();


        for (vector < const char*>::const_iterator i = symbolList.begin ();
                i != symbolList.end (); ++i)
        {
            const char* symbol =*i;
            MamdaSubscription*       aSubscription = new MamdaSubscription;
            MamdaBookAtomicListener* aBookListener = new MamdaBookAtomicListener;
            AtomicBookBuilder*       aBuilder       = new AtomicBookBuilder(symbol);

            /*
             * Add the book handler to recieve book begin and end callbacks
             */
            aBookListener->addBookHandler (aBuilder);


            /*
             * Add the level handler to handle level updates where available
             */
            aBookListener->addLevelHandler (aBuilder);

            /*
             * Add the entry handler to handle entry updates where available
             */
            aBookListener->addLevelEntryHandler (aBuilder);

            aBuilder->setShowEntries      (showEntries);
            aBuilder->setShowMarketOrders (showMarketOrders);
            aBuilder->setPrecision        (precision);

            aSubscription->addMsgListener     (aBookListener);
            aSubscription->addQualityListener (aBuilder);
            aSubscription->addErrorListener   (aBuilder);
            aSubscription->setType            (MAMA_SUBSC_TYPE_BOOK);
            aSubscription->setMdDataType      (MAMA_MD_DATA_TYPE_ORDER_BOOK);
            aSubscription->create             (queues->getNextQueue(), source, symbol);
            aBookListener->setProcessMarketOrders (processMarketOrders);
        }

        // Dispatch on the default MAMA queue
        Mama::start(bridge);
    }
    catch (MamaStatus& e)
    {
        cerr << "Exception in main (): " << e.toString () << endl;
        exit(EXIT_FAILURE);
    }
    catch (std::exception& ex)
    {
        cerr << "Exception in main (): " << ex.what () << endl;
        exit(EXIT_FAILURE);
    }
    catch (...)
    {
        cerr << "Unknown Exception in main ()." << endl;
        exit(EXIT_FAILURE);
    }

    return 0;
}
int main (int argc, const char **argv)
{
    try
    {
        CommonCommandLineParser     cmdLine (argc, argv);
        // Initialise the MAMA API
        mamaBridge bridge = cmdLine.getBridge();
        Mama::open ();

        const vector<const char*>&  symbolList    = cmdLine.getSymbolList ();
        MamaSource*                 source        = cmdLine.getSource();
        MamaSource*                 optionSource  = cmdLine.getOptionSource();
        int                         duration      = cmdLine.getOptInt ("duration");
        double                      timeout       = cmdLine.getTimeout ();
        MamaLogLevel                subscLogLevel = cmdLine.getSubscLogLevel();
        MamaQueueGroup  queues (cmdLine.getNumThreads(), bridge);

        double  throttleRate  = cmdLine.getThrottleRate ();
        if ((throttleRate > 100.0) || (throttleRate <= 0.0))
        {
            // We don't really want to swamp the FHs with these types of
            // subscriptions.  
            throttleRate = 100.0;
        }
        source->getTransport()->setOutboundThrottle (throttleRate,
                                                     MAMA_THROTTLE_DEFAULT);

        DictRequester   dictRequester (bridge);
        dictRequester.requestDictionary (cmdLine.getDictSource());
        MamdaTradeFields::setDictionary (*dictRequester.getDictionary());
        MamdaQuoteFields::setDictionary (*dictRequester.getDictionary());
        MamdaFundamentalFields::setDictionary (*dictRequester.getDictionary());
        MamdaOptionFields::setDictionary (*dictRequester.getDictionary());

        const char* symbolMapFile = cmdLine.getSymbolMapFile ();
        if (symbolMapFile)
        {
            MamaSymbolMapFile* aMap = new MamaSymbolMapFile;
            if (MAMA_STATUS_OK == aMap->load (symbolMapFile))
            {
                source->getTransport()->setSymbolMap (aMap);
                optionSource->getTransport()->setSymbolMap (aMap);
            }
        }

        for (vector<const char*>::const_iterator i = symbolList.begin ();
            i != symbolList.end ();
            ++i)
        {
            const char* symbol = *i;
            MamaQueue* queue = queues.getNextQueue();

            // Create chain and listener objects.
            MamdaTradeListener* aBaseTradeListener = new MamdaTradeListener;
            MamdaQuoteListener* aBaseQuoteListener = new MamdaQuoteListener;
            MamdaFundamentalListener* aFundamentalListener
                = new MamdaFundamentalListener;
            MamdaOptionChain*   anOptionChain = new MamdaOptionChain (symbol);
            anOptionChain->setUnderlyingQuoteListener (aBaseQuoteListener);
            anOptionChain->setUnderlyingTradeListener (aBaseTradeListener);
            MamdaOptionChainListener*  anOptionListener =
                new MamdaOptionChainListener (anOptionChain);

            // By Default Expirate Date , Strike Price and PutCall fields
            // are considered manditory to the creation of an option contract
            // Clear monditory status of each of these fields if so directed
            // n the command line.
            anOptionListener->setManditoryFields (
                !cmdLine.getOptBool ("noExpire"),
                !cmdLine.getOptBool ("noStrike"),
                !cmdLine.getOptBool ("noPutCall"));

            // Create our handlers (the UnderlyingTicker and
            // OptionChainDisplay could be a single class).
            UnderlyingTicker*   aBaseTicker = 
                new UnderlyingTicker (*anOptionChain);
            OptionChainDisplay*  aDisplay = 
                new OptionChainDisplay (*anOptionChain);

            // Create subscriptions for underlying and option chain:
            MamdaSubscription*  anOptionSubscription = new MamdaSubscription;

            // Register for underlying quote and trade events.
            aBaseTradeListener->addHandler (aBaseTicker);
            aBaseQuoteListener->addHandler (aBaseTicker);
            aFundamentalListener->addHandler (aBaseTicker);
 


            // Register for underlying option events.
            anOptionListener->addHandler (aDisplay);

            // The timeout defaults to 1 for this example because we
            // currently use the timeout feature to determine when
            // to say that we have received all of the initials.     
            anOptionSubscription->setTimeout (timeout);
            anOptionSubscription->addMsgListener (anOptionListener);
            anOptionSubscription->addQualityListener (aDisplay);
            anOptionSubscription->addErrorListener (aDisplay);
            anOptionSubscription->setType (MAMA_SUBSC_TYPE_GROUP);
            anOptionSubscription->create (queue, source, symbol);
            // logger...
            anOptionSubscription->getMamaSubscription ()->
                setDebugLevel (subscLogLevel);
        }
        
        ShutdownTimer shutdownCallback (bridge);
        MamaTimer     shutdownTimer;
        if (duration > 0)
        {
            shutdownTimer.create (Mama::getDefaultEventQueue (bridge), 
                                  &shutdownCallback, duration, 
                                  queues.getNextQueue());
        }
        Mama::start(bridge);
    }
    catch (MamaStatus &e)
    {
        
        // This exception can be thrown from Mama::start (),
        // Mama::createTransport (transportName) and from
        // MamdaSubscription constructor when entitlements is enabled.
        cerr << "Exception in main (): " << e.toString () << endl;
        exit (1);
    }
    catch (exception &ex)
    {
        cerr << "Exception in main (): " << ex.what () << endl;
        exit (1);
    }
    catch (...)
    {
        cerr << "Unknown Exception in main ()." << endl;
        exit (1);
    }
}
int main (int argc, const char* argv[])
{
    try
    {
        // Process some command line arguments:
        CommonCommandLineParser     cmdLine (argc, argv);
        // Initialise the MAMA API
        mamaBridge bridge = Mama::loadBridge (cmdLine.getMiddleware());
        Mama::open ();

        const vector<const char*>&  symbolList    = cmdLine.getSymbolList ();
        MamaSource*                 source        = cmdLine.getSource();
        MamaQueueGroup  queues (cmdLine.getNumThreads(), bridge);

        double  throttleRate  = cmdLine.getThrottleRate ();
        if ((throttleRate > 100.0) || (throttleRate <= 0.0))
        {
            // We don't really want to swamp the FHs with these types of
            // subscriptions.  
            throttleRate = 100.0;
        }
        source->getTransport()->setOutboundThrottle (throttleRate,
                                                     MAMA_THROTTLE_DEFAULT);

        DictRequester   dictRequester (bridge);
        dictRequester.requestDictionary (cmdLine.getDictSource());
        MamdaCommonFields::setDictionary (*dictRequester.getDictionary ());
        MamdaTradeFields::setDictionary (*dictRequester.getDictionary ());
        MamdaQuoteFields::setDictionary (*dictRequester.getDictionary ());

        const char* symbolMapFile = cmdLine.getSymbolMapFile ();
        if (symbolMapFile)
        {
            MamaSymbolMapFile* aMap = new MamaSymbolMapFile;
            if (MAMA_STATUS_OK == aMap->load (symbolMapFile))
            {
                source->getTransport()->setSymbolMap (aMap);
            }
        }

        for (vector<const char*>::const_iterator i = symbolList.begin ();
            i != symbolList.end ();
            ++i)
        {
            const char* symbol = *i;
            
            MamdaSubscription*  aSubscription  = new MamdaSubscription;
            
            MultiSecurityExample*  anExampleHandler =
                new MultiSecurityExample;
            
            MamdaMultiSecurityManager*  aSecurityManager =
                new MamdaMultiSecurityManager (symbol);

            aSecurityManager->addHandler (anExampleHandler);
            aSubscription->addMsgListener (aSecurityManager);
            aSubscription->setType (MAMA_SUBSC_TYPE_GROUP);
            aSubscription->create (queues.getNextQueue(), source, symbol);
        }

        Mama::start(bridge);
    }
    catch (MamaStatus &e)
    {
        // This exception can be thrown from Mama::start (),
        // Mama::createTransport (transportName) and from
        // MamdaSubscription constructor when entitlements is enabled.
        cerr << "MamaStatus exception in main (): " << e.toString () << endl;
        exit (1);
    }
    catch (exception &ex)
    {
        cerr << "Exception in main (): " << ex.what () << endl;
        exit (1);
    }
    catch (...)
    {
        cerr << "Unknown Exception in main ()." << endl;
        exit (1);
    }
    return 1;
}