Esempio n. 1
0
void BookPublisher::subscribeToSymbols () 
{ 

    for (vector<const char*>::const_iterator i = mSymbolList.begin ();
         i != mSymbolList.end ();
         ++i)
    {   
        const char* symbol = *i;
        mBook = new MamdaOrderBook();
        // Turn on delta generation
        mBook->generateDeltaMsgs(true);
        MamdaSubscription*      aSubscription = new MamdaSubscription;
        MamdaOrderBookListener* aBookListener = new MamdaOrderBookListener(mBook);
        aSubscription->addMsgListener (aBookListener);
        aBookListener->setProcessEntries (mProcessEntries);

        BookTicker* aTicker = new BookTicker;
        aBookListener->addHandler (aTicker);
       
        aSubscription->setType (MAMA_SUBSC_TYPE_BOOK);
        aSubscription->setMdDataType (MAMA_MD_DATA_TYPE_ORDER_BOOK);
        mSubscriptionList.push_back (aSubscription);

        aSubscription->create (Mama::getDefaultEventQueue (mBridge), mSubSource, symbol, NULL);

    }
}
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 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);
    }
}