public void LowWatermark( MamaQueue mamaQueue, int size, object closure) { Console.WriteLine(closure + "queue low water mark exceeded. Size " + size); }
private static MamaDictionary buildDataDictionary( MamaTransport transport, MamaQueue defaultQueue, MamaSource dictionarySource) { bool[] gotDict = new bool[] { false }; MamaDictionaryCallback dictionaryCallback = new DictionaryCallback(gotDict); lock (dictionaryCallback) { MamaSubscription subscription = new MamaSubscription (); MamaDictionary dictionary = new MamaDictionary(); dictionary.create( defaultQueue, dictionaryCallback, dictionarySource, 3, 10); Mama.start(myBridge); if (!gotDict[0]) { if (!Monitor.TryEnter(dictionaryCallback, 30000)) { Console.Error.WriteLine("Timed out waiting for dictionary."); Environment.Exit(0); } Monitor.Exit(dictionaryCallback); } return dictionary; } }
private static MamaDictionary buildDataDictionary( MamaTransport transport, MamaQueue defaultQueue, MamaSource dictionarySource) { bool[] gotDict = new bool[] { false }; MamaDictionaryCallback dictionaryCallback = new DictionaryCallback(gotDict); lock (dictionaryCallback) { MamaSubscription subscription = new MamaSubscription(); MamaDictionary dictionary = new MamaDictionary(); dictionary.create( defaultQueue, dictionaryCallback, dictionarySource, 3, 10); Mama.start(myBridge); if (!gotDict[0]) { if (!Monitor.TryEnter(dictionaryCallback, 30000)) { Console.Error.WriteLine("Timed out waiting for dictionary."); Environment.Exit(0); } Monitor.Exit(dictionaryCallback); } return(dictionary); } }
/// <summary> /// This is the thread procedure that is executed by the churn thread, it will keep /// churning subscriptions until the kill event is set. /// </summary> private void ChurnThreadProc() { for (; ;) { // Check the for kill event bool signal = m_killEvent.WaitOne(1000, false); // Quit the loop if the kill signal was received if (signal) { break; } // Churn subscriptions for (int j = 0; j < quota; j++) { int i = mamaRandom.Next(0, mamaNumSymbols); MamaTimer timer = new MamaTimer(); // Get the queue MamaQueue queue = mamaSubscriptions[i].subscQueue; if (queue != null) { timer.create(queue, this, m_churnTimeout, i); } } } }
/// <summary> /// MamaQueueMonitorCallback callbacks /// </summary> ///////////////////////////////////////////////////////////////////////////////////////////////// public void HighWatermarkExceeded( MamaQueue mamaQueue, int size, object closure) { Console.WriteLine(closure + " queue high water mark exceeded. Size " + size); }
public static void Main(string[] args) { MamaTransport transport = null; MamaQueue defaultQueue = null; MamaDictionary dictionary = null; ListenerCallback callback = new ListenerCallback(); CommandLineProcessor options = new CommandLineProcessor(args); try { // Initialize MAMA myBridge = new MamaBridge(options.getMiddleware()); Mama.open(); if (options.hasLogLevel()) { Mama.enableLogging(options.getLogLevel()); } transport = new MamaTransport(); transport.create(options.getTransport(), myBridge); defaultQueue = Mama.getDefaultEventQueue(myBridge); //Get the Data dictionary..... MamaSource dictionarySource = new MamaSource(); dictionarySource.symbolNamespace = options.getDictSource(); dictionarySource.transport = transport; dictionary = buildDataDictionary(transport, defaultQueue, dictionarySource); foreach (string symbol in options.getSymbolList()) { MamdaSubscription aSubscription = new MamdaSubscription(); aSubscription.addMsgListener(callback); aSubscription.addStaleListener(callback); aSubscription.addErrorListener(callback); if (options.getSnapshot()) { aSubscription.setServiceLevel(mamaServiceLevel.MAMA_SERVICE_LEVEL_SNAPSHOT, 0); } aSubscription.create(transport, defaultQueue, options.getSource(), symbol, null); mamdaSubscriptions.Add(aSubscription); } Console.WriteLine("Hit Enter or Ctrl-C to exit."); Mama.start(myBridge); GC.KeepAlive(dictionary); Console.ReadLine(); } catch (Exception e) { Console.Error.WriteLine(e.ToString()); Environment.Exit(1); } }
public StatsReport(MamaQueue mamaDefaultQueue) { statstimer = new MamaTimer(); statstimer.create(mamaDefaultQueue, this, 2, null); Console.WriteLine(" Time" + " {0, -4} {1, -4} {2, -4} {3, -4} {4, -2}", "Create", "Inital", "OtherMsg", "Error", "Recreate"); }
/// <summary> /// Will process an enqueued event, it will simply increment the count of /// the number of events. /// </summary> /// <param name="mamaQueue"> /// The queue. /// </param> /// <param name="closure"> /// Closure object. /// </param> void MamaQueueEventCallback.onEvent(MamaQueue mamaQueue, object closure) { // Increment the event count Interlocked.Increment(ref m_numberEvents); // Save the closure Interlocked.Exchange(ref m_closure, closure); // Fire the event to indicate a queue event has been processed m_event.Set(); }
/// <summary> /// This function will create subscriptions for all the symbols in the array list. /// </summary> private void createSubscriptions() { // There must be at least 1 symbol if (m_symbols.Count < 1) { throw new ApplicationException("There are no symbols to subscribe to."); } ListenerSubscriptionCallback subscriptionCallback = new ListenerSubscriptionCallback(m_dictionary, m_iterator, m_quietness, m_symbols.Count); // Enumerate all the symbol names and create a subscription for each one foreach (string symbol in m_symbols) { MamaSubscription subscription = new MamaSubscription(); // Set the service level depending on whether we need a snapshot subscription or not if (m_snapshot) { subscription.setServiceLevel(mamaServiceLevel.MAMA_SERVICE_LEVEL_SNAPSHOT); } else { subscription.setServiceLevel(mamaServiceLevel.MAMA_SERVICE_LEVEL_REAL_TIME); } // Complete the remaining properties subscription.setSubscriptionType(mamaSubscriptionType.MAMA_SUBSC_TYPE_NORMAL); subscription.setTimeout(10); subscription.setRetries(3); subscription.setRequiresInitial(true); /* Determine the queue to use, if there are multiple threads running then the next queue in the * group will be acquired. */ MamaQueue queue = m_defaultQueue; if (m_queueGroup != null) { queue = m_queueGroup.getNextQueue(); } subscription.create(queue, subscriptionCallback, m_source, symbol); // Add the subscription to the array list so that they can all be destroyed later on m_subscriptions.Add(subscription); } }
private static void initializeMama() { Mama.enableLogging(mamaLogLevel); try { myBridge = Mama.loadBridge(myMiddleware); /* Always the first API method called. Initialized internal API * state*/ Mama.open(); myDefaultQueue = Mama.getDefaultEventQueue(myBridge); } catch (Exception e) { Console.WriteLine(e.ToString()); Console.WriteLine("Failed to initialize MAMA"); Environment.Exit(1); } transport = new MamaTransport(); /* The name specified here is the name identifying properties in the * mama.properties file*/ transport.create(transportName, myBridge); if (myDictTportName != null) { myDictTransport = new MamaTransport(); myDictTransport.create(myDictTportName, myBridge); } else { myDictTransport = transport; } /*MamaSource for all subscriptions*/ mySource = new MamaSource(); mySource.transport = transport; mySource.symbolNamespace = mySymbolNamespace; /*MamaSource for dictionary subscription*/ myDictSource = new MamaSource(); myDictSource.transport = myDictTransport; myDictSource.symbolNamespace = dictSource; }
public void Setup() { // Load the wmw bridge m_bridge = Mama.loadBridge("lbm"); // Create the mama queue m_queue = new MamaQueue(m_bridge); // Create the auto reset event m_event = new AutoResetEvent(false); // Spin a thread to dispatch events m_dispatcher = new Thread(new ThreadStart(this.DispatcherThread)); // Reset all other member variables m_closure = null; m_numberEvents = 0; // Start the thread m_dispatcher.Start(); }
private void createQueues() { mamaDefaultQueue = Mama.getDefaultEventQueue(mamaBridge); mamaQueueGroup = new MamaQueueGroup(mamaBridge, mamaThreads); if (mamaThreads > 0) { // Has queue monitoring been enabled? if (mamaHighWaterMark > 0 || mamaLowWaterMark > 0) { for (int index = 0; index < mamaThreads; index++) { MamaQueue queue = mamaQueueGroup.getNextQueue(); string queueName = "QUEUE " + index; Console.WriteLine("Setting monitor for " + queueName); queue.setQueueMonitorCallbacks(this, queueName); if (mamaHighWaterMark > 0) { queue.setHighWatermark(mamaHighWaterMark); } if (mamaLowWaterMark > 0) { try { // Not supported on all middlewares. queue.setLowWatermark(mamaLowWaterMark); } catch (Exception e) { Console.WriteLine("Could not set " + queueName + " queue low water mark MamaStatus: " + e); } } } } } }
/// <summary> /// This function will initialise mama including loading the bridge and creating the queues and transports. /// </summary> private void initializeMama() { // Set the desired log level, (based on the number of 'v's passed on the command line) Mama.enableLogging(m_logLevel); m_bridge = Mama.loadBridge(m_middlewareName); Console.WriteLine(Mama.getVersion(m_bridge)); Mama.open(); m_defaultQueue = Mama.getDefaultEventQueue(m_bridge); // The transport must be created before the dictionary is downloaded createTransport(); createDictionary(); createQueues(); // Create the source needed to establish market data subscriptions createSource(); }
/// <summary> /// Queues will be created if the user has specified a number of threads to be /// used, otherwise the default queue will be used. /// </summary> private void createQueues() { // Only continue if the number of threads required is greater than 0 if (m_numberThreads > 0) { m_queueGroup = new MamaQueueGroup(m_bridge, m_numberThreads); if ((m_highWaterMark > 0) || (m_lowWaterMark > 0)) { ListenerQueueCallback queueCallback = new ListenerQueueCallback(); // Install the callback on each queue for (int index = 0; index < m_numberThreads; index++) { MamaQueue queue = m_queueGroup.getNextQueue(); string queueName = ("QUEUE " + index); Console.WriteLine("Setting monitor for " + queueName); // Install the callbacks queue.setQueueMonitorCallbacks(queueCallback, queueName); // Set the watermarks at which the callbacks are invoked if (m_highWaterMark > 0) { queue.setHighWatermark(m_highWaterMark); } if (m_lowWaterMark > 0) { // Not supported on all middlewares. queue.setLowWatermark(m_lowWaterMark); } } } } }
public void LowWatermark(MamaQueue mamaQueue, int size, object closure) { Console.WriteLine("Default queue high water mark exceeded. Size " + size); }
static void Main(string[] args) { // Parse the command line options to override defaults String middlewareName = "qpid"; String transportName = "sub"; String sourceName = "OM"; String symbolName = null; String dictionaryFile = "/opt/openmama/data/dictionaries/data.dict"; bool requiresDictionary = true; bool requiresInitial = true; if (args.Length == 0) { usageAndExit(); } for (int i = 0; i < args.Length; i++) { switch (args[i]) { case "-B": requiresDictionary = false; break; case "-d": dictionaryFile = args[++i]; break; case "-I": requiresInitial = false; break; case "-m": middlewareName = args[++i]; break; case "-s": symbolName = args[++i]; break; case "-S": sourceName = args[++i]; break; case "-t": transportName = args[++i]; break; case "-v": Mama.enableLogging(MamaLogLevel.MAMA_LOG_LEVEL_FINEST); break; default: usageAndExit(); break; } } // Symbol name is mandatory here, so error if it's null if (symbolName == null) { usageAndExit(); } // Load the requested OpenMAMA middleware bridge (and default payload too) MamaBridge bridge = Mama.loadBridge(middlewareName); // Time to initialize OpenMAMA's underlying bridges with an "open" Mama.open(); // Get default event queue from the bridge for testing MamaQueue queue = Mama.getDefaultEventQueue(bridge); // Set up the required transport on the specified bridge MamaTransport transport = new MamaTransport(); transport.create(transportName, bridge); // Set up the data dictionary MamaDictionary dictionary = null; if (requiresDictionary) { dictionary = new MamaDictionary(); dictionary.create(dictionaryFile); } // Set up the OpenMAMA source (symbol namespace) MamaSource source = new MamaSource(); source.symbolNamespace = sourceName; source.transport = transport; // Set up the event handlers for OpenMAMA SubscriptionEventHandler eventHandler = new SubscriptionEventHandler(); eventHandler.mDictionary = dictionary; // Set up the OpenMAMA Subscription (interest in a topic) MamaSubscription subscription = new MamaSubscription(); subscription.setRequiresInitial(requiresInitial); subscription.create(queue, eventHandler, source, symbolName); // Kick off OpenMAMA now (blocking call, non-blocking call also available) Mama.start(bridge); // Clean up connection on termination Mama.close(); }
static void Main(string[] args) { MamaTransport transport = null; MamaQueue defaultQueue = null; MamaDictionary dictionary = null; CommandLineProcessor options = new CommandLineProcessor(args); myQuietModeLevel = options.getQuietModeLevel(); if (options.hasLogLevel()) { myLogLevel = options.getLogLevel(); Mama.enableLogging(myLogLevel); } myCacheFullBooks = options.cacheFullBooks(); myPrintEntries = options.getPrintEntries(); mySnapshot = options.getSnapshot(); myPrecision = options.getPrecision(); try { //Initialize MAMA API myBridge = new MamaBridge(options.getMiddleware()); Mama.open(); transport = new MamaTransport(); transport.create(options.getTransport(), myBridge); defaultQueue = Mama.getDefaultEventQueue(myBridge); myMamaSource = new MamaSource(); //Get the Data dictionary..... MamaSource dictionarySource = new MamaSource(); dictionarySource.symbolNamespace = options.getDictSource(); dictionarySource.transport = transport; dictionary = buildDataDictionary(transport, defaultQueue, dictionarySource); MamdaOrderBookFields.setDictionary(dictionary, null); foreach (string symbol in options.getSymbolList()) { MamdaSubscription aSubscription = new MamdaSubscription(); MamdaOrderBookListener aBookListener; if (myCacheFullBooks) { aBookListener = new MamdaOrderBookListener(); } else { aBookListener = new MamdaOrderBookListener(null, new MamdaOrderBook()); } BookTicker aTicker = new BookTicker(); aBookListener.addHandler(aTicker); aSubscription.addMsgListener(aBookListener); aSubscription.addStaleListener(aTicker); aSubscription.addErrorListener(aTicker); aSubscription.setType(mamaSubscriptionType.MAMA_SUBSC_TYPE_BOOK); if (mySnapshot) { aSubscription.setServiceLevel(mamaServiceLevel.MAMA_SERVICE_LEVEL_SNAPSHOT, 0); } aSubscription.create( transport, defaultQueue, options.getSource(), symbol, null); mamdaSubscriptions.Add(aSubscription); } //Start dispatching on the default MAMA event queue Console.WriteLine("Hit Enter or Ctrl-C to exit."); Mama.start(myBridge); GC.KeepAlive(dictionary); Console.ReadLine(); } catch (Exception e) { Console.WriteLine(e.ToString()); Environment.Exit(1); } }
public static void Main(string[] args) { MamaTransport transport = null; MamaQueue defaultQueue = null; MamaDictionary dictionary = null; CommandLineProcessor options = new CommandLineProcessor(args); double throttleRate = options.getThrottleRate(); if (options.hasLogLevel()) { logLevel_ = options.getLogLevel(); Mama.enableLogging(logLevel_); } if ((throttleRate > 100.0) || (throttleRate <= 0.0)) { throttleRate = 100.0; } try { // Initialize MAMDA myBridge = new MamaBridge(options.getMiddleware()); Mama.open(); transport = new MamaTransport(); transport.create(options.getTransport(), myBridge); defaultQueue = Mama.getDefaultEventQueue(myBridge); //Get the Data dictionary..... MamaSource dictionarySource = new MamaSource(); dictionarySource.symbolNamespace = options.getDictSource(); dictionarySource.transport = transport; dictionary = buildDataDictionary(transport, defaultQueue, dictionarySource); //Initialise the dictionary and fields MamdaCommonFields.setDictionary(dictionary, null); MamdaQuoteFields.setDictionary(dictionary, null); MamdaTradeFields.setDictionary(dictionary, null); foreach (string symbol in options.getSymbolList()) { MamdaSubscription aSubscription = new MamdaSubscription(); aSubscription.setType(mamaSubscriptionType.MAMA_SUBSC_TYPE_GROUP); aSubscription.setTimeout(60.0); aSubscription.create( transport, defaultQueue, options.getSource(), symbol, null); /* For each subscription a MamdaMultiSecurityicipantManager is * added as the message listener. The callbacks on the * MamdaMultiSecurityHandler will be invokes as new group members * become available.*/ MamdaMultiSecurityManager multiSecurityManager = new MamdaMultiSecurityManager(symbol); multiSecurityManager.addHandler(new MultiSecurityHandler()); aSubscription.addMsgListener(multiSecurityManager); aSubscription.activate(); mamdaSubscriptions.Add(aSubscription); } Mama.start(myBridge); GC.KeepAlive(dictionary); Console.WriteLine("Press ENTER or Ctrl-C to quit..."); Console.ReadLine(); } catch (Exception e) { Console.WriteLine(e.ToString()); Environment.Exit(1); } }
public static void Main(string[] args) { try { options = new CommandLineProcessor(args); //Getting the log File name myLogFileName = options.getLogFileName(); if (myLogFileName != null) { myOutFile = new FileStream(myLogFileName, FileMode.OpenOrCreate); myOut = new StreamWriter(myOutFile); myOut.WriteLine("Date/Time"+ "," + "ChurnStats" +"," + "UpdateStats" + "," + "PeakMsgCount" + "," + "RecapStats" + "," + "BookGapStats" + "," +"freeMemory" +"," +"Memory Used"); } else { myOut = Console.Out; } // Initialize MAMA bridge = new MamaBridge(options.getMiddleware()); Mama.open(); if (options.hasLogLevel()) { myLogLevel = options.getLogLevel(); Mama.enableLogging(myLogLevel); } transport = new MamaTransport(); transport.create(options.getTransport(), bridge); defaultQueue = Mama.getDefaultEventQueue(bridge); //Get the Data dictionary..... MamaSource dictionarySource = new MamaSource(); dictionarySource.symbolNamespace = options.getDictSource(); dictionarySource.transport = transport; dictionary = buildDataDictionary(transport, defaultQueue, dictionarySource); MamdaOrderBookFields.setDictionary(dictionary, null); foreach (string symbol in options.getSymbolList()) { subscribeToBooks(symbol); } myChurnRate = options.getChurnRate(); Thread.Sleep(10000); //Getting the TimerInterval from the cmd prompt myChurnInterval = options.getTimerInterval(); //Churn Timer if (myChurnRate > 0) { myChurnTimer = safeCreateTimer(new ChurnCallback(), myChurnInterval); } //Stats Timer myStatsTimer = safeCreateTimer(new StatsCallback(), 1.0); Console.WriteLine("Hit Enter or Ctrl-C to exit."); Mama.start(bridge); GC.KeepAlive(dictionary); Console.ReadLine(); if (myOutFile != null) { myOut.Close(); } } catch (Exception e) { Console.Error.WriteLine(e.ToString()); Environment.Exit(1); } }
public static void Main(string[] args) { CommandLineProcessor options = new CommandLineProcessor(args); MamaTransport transport = null; MamaQueue defaultQueue = null; MamaDictionary dictionary = null; double intervalSecs = options.getTimerInterval(); if (options.hasLogLevel()) { myLogLevel = options.getLogLevel(); Mama.enableLogging(myLogLevel); } try { myBridge = new MamaBridge(options.getMiddleware()); Mama.open(); transport = new MamaTransport(); transport.create(options.getTransport(), myBridge); mySource = new MamaSource(); defaultQueue = Mama.getDefaultEventQueue(myBridge); // We might as well also enforce strict checking of order book updates MamdaOrderBook.setStrictChecking(true); /*Get the Data Dictionary*/ MamaSource dictionarySource = new MamaSource(); dictionarySource.symbolNamespace = "WOMBAT"; dictionarySource.transport = transport; dictionary = buildDataDictionary(transport, defaultQueue, dictionarySource); MamdaOrderBookFields.setDictionary(dictionary, null); if (intervalSecs == 0) { intervalSecs = 5; } foreach (string symbol in options.getSymbolList()) { BookSelfTest aSelfTest = new BookSelfTest(); MamdaOrderBookChecker aBookChecker = new MamdaOrderBookChecker( transport, defaultQueue, aSelfTest, options.getSource(), symbol, intervalSecs); obookCheckers.Add(aBookChecker); } Mama.start(myBridge); GC.KeepAlive(dictionary); } catch (Exception ex) { Console.WriteLine(ex.ToString()); Environment.Exit(1); } }
public static void Main(string[] args) { MamaTransport baseTransport = null; MamaTransport optionTransport = null; MamaTransport dictTransport = null; string dictTransportName = null; MamaQueue defaultQueue = null; MamaDictionary dictionary = null; CommandLineProcessor options = new CommandLineProcessor(args); if (options.hasLogLevel()) { logLevel_ = options.getLogLevel(); Mama.enableLogging(logLevel_); } try { // Initialize MAMA myBridge = new MamaBridge(options.getMiddleware()); Mama.open(); // Initialize transports. We're assuming that options and // underlyings might be on different transports. Note: // some companies might use multiple transports for // underlyings (e.g., CTA and NASDAQ), which case it would // be necessary to create three transports here and be // sure to pass the correct transport later. baseTransport = new MamaTransport(); baseTransport.create(options.getTransport(), myBridge); optionTransport = baseTransport; defaultQueue = Mama.getDefaultEventQueue(myBridge); // Fetch and initialize the data dictionary MamaSource dictionarySource = new MamaSource(); dictionarySource.symbolNamespace = options.getDictSource(); dictTransportName = options.getDictTransport(); if (null != dictTransportName) { dictTransport = new MamaTransport(); dictTransport.create(dictTransportName, myBridge); } else { dictTransport = baseTransport; } dictionarySource.transport = dictTransport; dictionary = buildDataDictionary(dictTransport, defaultQueue, dictionarySource); MamdaQuoteFields.setDictionary(dictionary, null); MamdaTradeFields.setDictionary(dictionary, null); MamdaFundamentalFields.setDictionary(dictionary, null); MamdaOptionFields.setDictionary(dictionary, null); // Create listeners for each chain. Two subscriptions are // necessary. foreach (string symbol in options.getSymbolList()) { // Create chain and listener objects. MamdaTradeListener aBaseTradeListener = new MamdaTradeListener(); MamdaQuoteListener aBaseQuoteListener = new MamdaQuoteListener(); MamdaOptionChain anOptionChain = new MamdaOptionChain(symbol); anOptionChain.setUnderlyingQuoteListener(aBaseQuoteListener); anOptionChain.setUnderlyingTradeListener(aBaseTradeListener); MamdaOptionChainListener anOptionListener = new MamdaOptionChainListener(anOptionChain); // Create our handlers (the UnderlyingTicker and // OptionChainDisplay could be a single class). UnderlyingTicker aBaseTicker = new UnderlyingTicker(anOptionChain, true); OptionChainDisplay aDisplay = new OptionChainDisplay(anOptionChain); // Create subscriptions for underlying and option chain: MamdaSubscription aBaseSubscription = new MamdaSubscription(); MamdaSubscription anOptionSubscription = new MamdaSubscription(); // Register for underlying quote and trade events. aBaseTradeListener.addHandler(aBaseTicker); aBaseQuoteListener.addHandler(aBaseTicker); aBaseSubscription.addMsgListener(aBaseTradeListener); aBaseSubscription.addMsgListener(aBaseQuoteListener); aBaseSubscription.create( baseTransport, defaultQueue, options.getSource(), symbol, null); mamdaSubscriptions.Add(aBaseSubscription); // Register for underlying option events. anOptionListener.addHandler(aDisplay); // We set the timeout 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. // There will be a separate time interval for this in // the future. anOptionSubscription.setTimeout(1); anOptionSubscription.addMsgListener(anOptionListener); anOptionSubscription.addStaleListener(aDisplay); anOptionSubscription.addErrorListener(aDisplay); anOptionSubscription.setType(mamaSubscriptionType.MAMA_SUBSC_TYPE_GROUP); anOptionSubscription.create( optionTransport, defaultQueue, options.getSource(), symbol, null); optionSubscriptions.Add(anOptionSubscription); } //Start dispatching on the default event queue Mama.start(myBridge); GC.KeepAlive(dictionary); Console.WriteLine("Press ENTER or Ctrl-C to quit..."); Console.ReadLine(); } catch (Exception e) { Console.WriteLine(e.ToString()); Environment.Exit(1); } }
static void Main(string[] args) { MamaTransport transport = null; MamaQueue defaultQueue = null; MamaDictionary dictionary = null; CommandLineProcessor options = new CommandLineProcessor(args); myQuietModeLevel = options.getQuietModeLevel(); if (options.hasLogLevel()) { myLogLevel = options.getLogLevel(); Mama.enableLogging(myLogLevel); } try { //Initialize MAMA API myBridge = new MamaBridge(options.getMiddleware()); Mama.open(); transport = new MamaTransport(); transport.create(options.getTransport(), myBridge); defaultQueue = Mama.getDefaultEventQueue(myBridge); myMamaSource = new MamaSource(); //Get the Data dictionary..... MamaSource dictionarySource = new MamaSource(); dictionarySource.symbolNamespace = "WOMBAT"; dictionarySource.transport = transport; dictionary = buildDataDictionary(transport, defaultQueue, dictionarySource); MamdaQuoteFields.setDictionary(dictionary, null); MamdaTradeFields.setDictionary(dictionary, null); MamdaCommonFields.setDictionary(dictionary, null); MamdaOrderBookFields.setDictionary(dictionary, null); myQueueGroup = new MamaQueueGroup(myBridge, options.getNumThreads()); foreach (string symbol in options.getSymbolList()) { MamdaSubscription aSubscription = new MamdaSubscription(); MamdaBookAtomicListener aBookListener = new MamdaBookAtomicListener(); AtomicBookTicker aTicker = new AtomicBookTicker(); aBookListener.addBookHandler(aTicker); aBookListener.addLevelHandler(aTicker); if (options.getPrintEntries()) { // Entries aBookListener.addLevelEntryHandler(aTicker); } aSubscription.addMsgListener(aBookListener); aSubscription.addStaleListener(aTicker); aSubscription.addErrorListener(aTicker); aSubscription.setType(mamaSubscriptionType.MAMA_SUBSC_TYPE_BOOK); aSubscription.create(transport, myQueueGroup.getNextQueue(), options.getSource(), symbol, null); mamdaSubscriptions.Add(aSubscription); } //Start dispatching on the default MAMA event queue Console.WriteLine("Hit Enter or Ctrl-C to exit."); Mama.start(myBridge); GC.KeepAlive(dictionary); Console.ReadLine(); } catch (Exception e) { Console.WriteLine(e.ToString()); Environment.Exit(1); } }
public static void Main(string[] args) { MamaTransport transport = null; MamaQueue defaultQueue = null; MamaDictionary dictionary = null; CommandLineProcessor options = new CommandLineProcessor(args); myQuietModeLevel = options.getQuietModeLevel(); if (options.hasLogLevel()) { Mama.enableLogging(options.getLogLevel()); } try { // Initialize MAMDA myBridge = new MamaBridge(options.getMiddleware()); Mama.open(); transport = new MamaTransport(); transport.create(options.getTransport(), myBridge); defaultQueue = Mama.getDefaultEventQueue(myBridge); /*Get the data dictionary*/ MamaSource dictionarySource = new MamaSource(); dictionarySource.symbolNamespace = "WOMBAT"; dictionarySource.transport = transport; dictionary = buildDataDictionary(transport, defaultQueue, dictionarySource); MamdaAuctionFields.setDictionary(dictionary, null); mamdaSubscriptions = new MamdaSubscription [options.getSymbolList().Count]; int i = 0; foreach (string symbol in options.getSymbolList()) { mamdaSubscriptions[i] = new MamdaSubscription(); MamdaAuctionListener aAuctionListener = new MamdaAuctionListener(); AuctionTicker aTicker = new AuctionTicker(); aAuctionListener.addHandler(aTicker); mamdaSubscriptions[i].addMsgListener(aAuctionListener); mamdaSubscriptions[i].addStaleListener(aTicker); mamdaSubscriptions[i].addErrorListener(aTicker); mamdaSubscriptions[i].create(transport, defaultQueue, options.getSource(), symbol, null); i++; } Console.WriteLine("Hit Enter or Ctrl-C to exit."); Mama.start(myBridge); GC.KeepAlive(dictionary); Console.ReadLine(); } catch (Exception e) { Console.Error.WriteLine(e.ToString()); Environment.Exit(1); } }
public static void Main(string[] args) { MamaTransport transport = null; MamaTransport dictTransport = null; string dictTransportName = null; MamaQueue defaultQueue = null; MamaDictionary dictionary = null; CommandLineProcessor options = new CommandLineProcessor(args); if (options.hasLogLevel()) { Mama.enableLogging(options.getLogLevel()); } try { // Initialize MAMDA myBridge = new MamaBridge(options.getMiddleware()); Mama.open(); transport = new MamaTransport(); myMamaSource = new MamaSource(); transport.create(options.getTransport(), myBridge); defaultQueue = Mama.getDefaultEventQueue(myBridge); MamaSource dictionarySource = new MamaSource(); dictionarySource.symbolNamespace = "WOMBAT"; dictTransportName = options.getDictTransport(); if (null != dictTransportName) { dictTransport = new MamaTransport(); dictTransport.create(dictTransportName, myBridge); } else { dictTransport = transport; } dictionarySource.transport = dictTransport; /*Get the data dictionary*/ dictionary = buildDataDictionary(dictTransport, defaultQueue, dictionarySource); MamdaFundamentalFields.setDictionary(dictionary, null); foreach (string symbol in options.getSymbolList()) { MamdaSubscription aSubscription = new MamdaSubscription(); MamdaFundamentalListener aSecListener = new MamdaFundamentalListener(); FundTicker aTicker = new FundTicker(); aSecListener.addHandler(aTicker); aSubscription.addMsgListener(aSecListener); aSubscription.create(transport, defaultQueue, options.getSource(), symbol, null); } Console.WriteLine("Hit Enter or Ctrl-C to exit."); Mama.start(myBridge); GC.KeepAlive(dictionary); Console.ReadLine(); } catch (Exception e) { Console.Error.WriteLine(e.ToString()); Environment.Exit(1); } }