/// <summary> /// This function will clean up all the objects initialised before Mama.start is called. /// </summary> private void uninitializeMama() { if (m_source != null) { m_source.destroy(); m_source = null; } if (m_dictionary != null) { m_dictionary.Dispose(); m_dictionary = null; } if (m_queueGroup != null) { m_queueGroup.destroyWait(); m_queueGroup = null; } if (m_transport != null) { m_transport.destroy(); m_transport = null; } Mama.close(); }
private static void subscribeToSubjects() { int howMany = 0; queueGroup = new MamaQueueGroup(myBridge, numThreads); /* Subscribe to all symbols parsed from the symbol list */ for (IEnumerator enumerator = subjectList.GetEnumerator(); enumerator.MoveNext();) { string symbol = (string)enumerator.Current; MamaSubscription subscription = new MamaSubscription(); subscription.create( queueGroup.getNextQueue(), subscriptionCallback, mySource, symbol, null); subscriptions.Add(subscription); if (++howMany % 1000 == 0) { Console.WriteLine("Subscribed to " + howMany + " symbols."); } } }
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> /// 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 Setup() { // Set the logging to this level Mama.enableLogging(MamaLogLevel.MAMA_LOG_LEVEL_FINEST); MamaCommon.getCmdLineArgs(); createCount = 0; errorCount = 0; destroyCount = 0; // Load the wmw bridge m_bridge = Mama.loadBridge(MamaCommon.middlewareName); Mama.open(); Mama.log(MamaLogLevel.MAMA_LOG_LEVEL_FINE, "MamaPublisherTest.Setup: transport=" + MamaCommon.middlewareName + " tport=" + MamaCommon.transportName + " source=" + MamaCommon.source + " symbol=" + MamaCommon.symbol); // Create the mama queue m_queueGroup = new MamaQueueGroup(m_bridge, 1); m_msg = new MamaMsg(); m_transport = new MamaTransport(); m_transport.create(MamaCommon.transportName, m_bridge); Mama.startBackground(m_bridge, this); Thread.Sleep(1000); GC.KeepAlive(m_bridge); GC.KeepAlive(m_transport); GC.KeepAlive(m_queueGroup); GC.KeepAlive(m_msg); }
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); } }
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); } }