public create ( string name, Wombat.MamaBridge bridgeImpl ) : void | ||
name | string | |
bridgeImpl | Wombat.MamaBridge | |
리턴 | void |
private MamaSubscriberCS(string[] args) { try { if (parseCommandLine(args)) { mamaBridge = Mama.loadBridge(middlewareName); Mama.open(); mamaTransport = new MamaTransport(); mamaTransport.setTransportCallback(this); mamaTransport.create(transportName, mamaBridge); mamaDefaultQueue = Mama.getDefaultEventQueue(mamaBridge); mamaSubscription = new MamaSubscription(); mamaSubscription.createBasic( mamaTransport, mamaDefaultQueue, this, // callback topicName); Console.WriteLine("Starting mama..."); Mama.start(mamaBridge); // Prevent over-enthusiastic GC from reclaiming transport object GC.KeepAlive(mamaTransport); } } catch (Exception e) { Console.WriteLine(e.Message); } }
private MamaSubscriberCS(string[] args) { try { if (parseCommandLine(args)) { mamaBridge = Mama.loadBridge(middlewareName); Mama.open(); mamaTransport = new MamaTransport(); mamaTransport.setTransportCallback(this); mamaTransport.create(transportName, mamaBridge); mamaDefaultQueue = Mama.getDefaultEventQueue(mamaBridge); mamaSubscription = new MamaSubscription(); mamaSubscription.createBasic( mamaTransport, mamaDefaultQueue, this, // callback topicName); Console.WriteLine("Starting mama..."); Mama.start(mamaBridge); // Prevent over-enthusiastic GC from reclaiming transport object GC.KeepAlive(mamaTransport); } } catch (Exception e) { Console.WriteLine(e.Message); } }
public int Run() { ParseArgs(); if (helpNeeded) { DisplayUsage(); return(0); } Mama.logToFile(@"mama.log", MamaLogLevel.MAMA_LOG_LEVEL_FINEST); bridge = Mama.loadBridge(middlewareName); Mama.open(); MamaTransport transport = new MamaTransport(); MamaQueue defaultQueue = Mama.getDefaultEventQueue(bridge); MamaTimer timer = new MamaTimer(); MamaSubscription subscription = new MamaSubscription(); MamaPublisherCS publisher = this; transport.create(transportName, bridge); timer.create(defaultQueue, publisher, interval, null); subscription.createBasic(transport, defaultQueue, publisher, inboundTopic); publisher.create(transport, outboundTopic); msg = new MamaMsg(); Mama.start(bridge); Mama.close(); return(0); }
private void createSubscriber(MamaBridge bridge) { MamaSubscription mamaSubscription = new MamaSubscription(); MamaTransport mamaTransport = new MamaTransport(); MamaQueue mamaDefaultQueue = Mama.getDefaultEventQueue(bridge); Dispatcher dispatcher = new Dispatcher(bridge); mamaTransport = new MamaTransport(); mamaTransport.setTransportCallback(this); mamaTransport.create(transportName, bridge); mamaSubscription = new MamaSubscription(); mamaSubscription.createBasic( mamaTransport, mamaDefaultQueue, this, // callback topicName); Console.WriteLine("Starting mama..."); mamaSubscriptions.Add(mamaSubscription); mamaTransports.Add(mamaTransport); Thread startThread = new Thread(new ThreadStart(dispatcher.dispatch)); startThread.Start(); }
public int Run() { ParseArgs(); if (helpNeeded) { DisplayUsage(); return(0); } Mama.logToFile(@"mama.log", MamaLogLevel.MAMA_LOG_LEVEL_NORMAL); bridge = Mama.loadBridge(middlewareName); Mama.open(); MamaQueue defaultQueue = Mama.getDefaultEventQueue(bridge); msg = new MamaMsg(); MamaTimer timer = new MamaTimer(); timer.create(defaultQueue, this, interval, null); queueGroup = new MamaQueueGroup(bridge, 1); MamaTransport transport = new MamaTransport(); transport.create(transportName, bridge); MamaSubscription subscription = null; if (nosub == false) { subscription = new MamaSubscription(); subscription.createBasic(transport, defaultQueue, this, inboundTopic); } publisher = new MamaPublisher(); if (pubCb) { publisher.createWithCallbacks(transport, queueGroup.getNextQueue(), this, null, outboundTopic, null, null); } else { publisher.create(transport, outboundTopic); } Mama.start(bridge); Mama.close(); return(0); }
private void InitializeMama() { try { Mama.logToFile(@"mama.log", MamaLogLevel.MAMA_LOG_LEVEL_FINEST); bridge = new MamaBridge(middlewareName); Mama.open(); transport = new MamaTransport(); transport.create(transportName, bridge); defaultQueue = Mama.getDefaultEventQueue(bridge); } catch (MamaException e) { Console.WriteLine("Error initializing mama or creating transport: {0}", e.ToString()); Exit(1); } }
private void createSubscriber (MamaBridge bridge) { MamaSubscription mamaSubscription = new MamaSubscription(); MamaTransport mamaTransport = new MamaTransport(); MamaQueue mamaDefaultQueue = Mama.getDefaultEventQueue(bridge); Dispatcher dispatcher = new Dispatcher(bridge); mamaTransport = new MamaTransport(); mamaTransport.setTransportCallback(this); mamaTransport.create(transportName, bridge); mamaSubscription = new MamaSubscription(); mamaSubscription.createBasic( mamaTransport, mamaDefaultQueue, this, // callback topicName); Console.WriteLine("Starting mama..."); mamaSubscriptions.Add(mamaSubscription); mamaTransports.Add(mamaTransport); Thread startThread = new Thread (new ThreadStart(dispatcher.dispatch)); startThread.Start(); }
private void parseCommandLine(string[] args) { string tport = null; uint ft_type = (uint)mamaFtType.MAMA_FT_TYPE_MULTICAST; bool displayVersion = false; for (int i = 0; i < args.Length; ) { if ((args[i].CompareTo ("-h")) == 0 || (args[i].CompareTo ("-?")) == 0) { usage (0); } if ((args[i].CompareTo ("-g") == 0) || (args[i].CompareTo ("-group") == 0)) { myGroup = args[i+1]; i += 2; continue; } if ((args[i].CompareTo ("-w") == 0) || (args[i].CompareTo ("-weight") == 0)) { myWeight = Convert.ToUInt32 (args[i+1]); i += 2; continue; } if (args[i].CompareTo ("-m") == 0) { myMiddleware = args[i+1]; i += 2; continue; } if ((args[i].CompareTo ("-t") == 0) || (args[i].CompareTo ("-tport") == 0)) { tport = args[i+1]; i += 2; continue; } if (args[i].CompareTo ("-v") == 0) { if (mamaLogLevel == MamaLogLevel.MAMA_LOG_LEVEL_WARN) { mamaLogLevel = MamaLogLevel.MAMA_LOG_LEVEL_NORMAL; Mama.enableLogging (mamaLogLevel); } else if (mamaLogLevel == MamaLogLevel.MAMA_LOG_LEVEL_NORMAL) { mamaLogLevel = MamaLogLevel.MAMA_LOG_LEVEL_FINE; Mama.enableLogging (mamaLogLevel); } else if (mamaLogLevel == MamaLogLevel.MAMA_LOG_LEVEL_FINE) { mamaLogLevel = MamaLogLevel.MAMA_LOG_LEVEL_FINER; Mama.enableLogging (mamaLogLevel); } else { mamaLogLevel = MamaLogLevel.MAMA_LOG_LEVEL_FINEST; Mama.enableLogging (mamaLogLevel); } i++; continue; } if (args[i].CompareTo ("-version") == 0) { displayVersion = true; break; } if (args[i].CompareTo ("-b") == 0) { ft_type = (uint)mamaFtType.MAMA_FT_TYPE_BRIDGE; i++; continue; } i++; } myBridge = Mama.loadBridge(myMiddleware); Mama.open(); if (displayVersion) { Console.WriteLine (Mama.getVersion (myBridge)); Exit (0); } myTimer = new MamaTimer(); myTransport = new MamaTransport(); myTransport.create(tport, myBridge); if (myGroup == null) { Console.WriteLine ("No FT group name specified"); usage(1); } switch (ft_type) { case (uint)mamaFtType.MAMA_FT_TYPE_MULTICAST: myFtMember = new MamaMulticastFtMember (); break; case (uint)mamaFtType.MAMA_FT_TYPE_BRIDGE: myFtMember = new MamaBridgeFtMember (); break; default: Console.WriteLine ("No FT type specified"); usage(1); break; } }
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.create( transport, defaultQueue, options.getSource(), symbol, null); /* For each subscription a MamdaMultiParticipantManager is * added as the message listener. The callbacks on the * MamdaMultiPartHandler will be invokes as new group members * become available.*/ MamdaMultiParticipantManager multiPartManager = new MamdaMultiParticipantManager(symbol); multiPartManager.addHandler(new MultiPartHandler()); aSubscription.addMsgListener(multiPartManager); 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); } }
/// <summary> /// This function will create the dictionary. /// </summary> private void createDictionary() { if (m_downloadDictionary) { using (MamaSource dictionarySource = new MamaSource()) { /* If a dictionary transport has been specified then a new one must be created otherwise * the main transport will be re-used. */ MamaTransport dictionaryTransport = null; try { if((m_dictionaryTransportName == null) || (m_dictionaryTransportName == string.Empty)) { dictionarySource.transport = m_transport; } else { dictionaryTransport = new MamaTransport(); dictionaryTransport.create(m_dictionaryTransportName, m_bridge); dictionarySource.transport = dictionaryTransport; } // The symbol namespace must also be set dictionarySource.symbolNamespace = m_dictionarySourceName; // Instantiate a callback class ListenerDictionaryCallback dictionaryCallback = new ListenerDictionaryCallback(m_bridge); // Create the actual dictionary object using the default queue m_dictionary = new MamaDictionary(); m_dictionary.create(m_defaultQueue, dictionaryCallback, dictionarySource, 3, 10.0); // Start the bridge, this will block until the dictionary is downloaded or something goes wrong Mama.start(m_bridge); // If something went wrong then throw an exception if (!dictionaryCallback.DictionaryComplete) { throw new ApplicationException("Can't create dictionary."); } } finally { if (dictionaryTransport != null) { dictionaryTransport.destroy(); } } } } }
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; }
private void parseCommandLine(string[] args) { string tport = null; uint ft_type = (uint)mamaFtType.MAMA_FT_TYPE_MULTICAST; bool displayVersion = false; for (int i = 0; i < args.Length;) { if ((args[i].CompareTo("-h")) == 0 || (args[i].CompareTo("-?")) == 0) { usage(0); } if ((args[i].CompareTo("-g") == 0) || (args[i].CompareTo("-group") == 0)) { myGroup = args[i + 1]; i += 2; continue; } if ((args[i].CompareTo("-w") == 0) || (args[i].CompareTo("-weight") == 0)) { myWeight = Convert.ToUInt32(args[i + 1]); i += 2; continue; } if (args[i].CompareTo("-m") == 0) { myMiddleware = args[i + 1]; i += 2; continue; } if ((args[i].CompareTo("-t") == 0) || (args[i].CompareTo("-tport") == 0)) { tport = args[i + 1]; i += 2; continue; } if (args[i].CompareTo("-v") == 0) { if (mamaLogLevel == MamaLogLevel.MAMA_LOG_LEVEL_WARN) { mamaLogLevel = MamaLogLevel.MAMA_LOG_LEVEL_NORMAL; Mama.enableLogging(mamaLogLevel); } else if (mamaLogLevel == MamaLogLevel.MAMA_LOG_LEVEL_NORMAL) { mamaLogLevel = MamaLogLevel.MAMA_LOG_LEVEL_FINE; Mama.enableLogging(mamaLogLevel); } else if (mamaLogLevel == MamaLogLevel.MAMA_LOG_LEVEL_FINE) { mamaLogLevel = MamaLogLevel.MAMA_LOG_LEVEL_FINER; Mama.enableLogging(mamaLogLevel); } else { mamaLogLevel = MamaLogLevel.MAMA_LOG_LEVEL_FINEST; Mama.enableLogging(mamaLogLevel); } i++; continue; } if (args[i].CompareTo("-version") == 0) { displayVersion = true; break; } if (args[i].CompareTo("-b") == 0) { ft_type = (uint)mamaFtType.MAMA_FT_TYPE_BRIDGE; i++; continue; } i++; } myBridge = Mama.loadBridge(myMiddleware); Mama.open(); if (displayVersion) { Console.WriteLine(Mama.getVersion(myBridge)); Exit(0); } myTimer = new MamaTimer(); myTransport = new MamaTransport(); myTransport.create(tport, myBridge); if (myGroup == null) { Console.WriteLine("No FT group name specified"); usage(1); } switch (ft_type) { case (uint)mamaFtType.MAMA_FT_TYPE_MULTICAST: myFtMember = new MamaMulticastFtMember(); break; case (uint)mamaFtType.MAMA_FT_TYPE_BRIDGE: myFtMember = new MamaBridgeFtMember(); break; default: Console.WriteLine("No FT type specified"); usage(1); break; } }
public int Run() { ParseArgs(); if (helpNeeded) { DisplayUsage(); return 0; } Mama.logToFile(@"mama.log", MamaLogLevel.MAMA_LOG_LEVEL_NORMAL); bridge = Mama.loadBridge(middlewareName); Mama.open(); MamaQueue defaultQueue = Mama.getDefaultEventQueue(bridge); msg = new MamaMsg(); MamaTimer timer = new MamaTimer(); timer.create(defaultQueue, this, interval, null); queueGroup = new MamaQueueGroup(bridge, 1); MamaTransport transport = new MamaTransport(); transport.create(transportName, bridge); MamaSubscription subscription = null; if (nosub == false) { subscription = new MamaSubscription(); subscription.createBasic(transport, defaultQueue, this, inboundTopic); } publisher = new MamaPublisher(); if (pubCb) { publisher.createWithCallbacks(transport, queueGroup.getNextQueue(), this, null, outboundTopic, null, null); } else { publisher.create(transport, outboundTopic); } Mama.start(bridge); Mama.close(); return 0; }
/// <summary> /// This function will create the mama transport using the values specified in the member /// variables. /// </summary> private void createTransport() { m_transport = new MamaTransport(); // Register for the callbacks before the transport is created m_transport.setTransportCallback(new ListenerTransportCallback()); // Set the throttle rate if one has been specified, note that 0 is valid and turns the throttle off if(m_throttleRate != -1) { m_transport.setOutboundThrottle(MamaTransport.MamaThrottleInstance.MAMA_THROTTLE_DEFAULT, m_throttleRate); } // Set the recap throttle rate if one has been specified, note that 0 is valid and turns the throttle off if(m_recapThrottleRate != -1) { m_transport.setOutboundThrottle(MamaTransport.MamaThrottleInstance.MAMA_THROTTLE_RECAP, m_recapThrottleRate); } // Create the transport now that everything has been set m_transport.create(m_transportName, m_bridge); }
private void initializeMama() { mamaBridge = Mama.loadBridge(mamaMiddlewareName); Console.WriteLine(Mama.getVersion(mamaBridge)); Mama.open(); if (mamaHighWaterMark > 0 || mamaLowWaterMark > 0) { if (mamaHighWaterMark > 0) { Mama.setDefaultQueueHighWatermark(mamaHighWaterMark); } if (mamaLowWaterMark > 0) { try { Mama.setDefaultQueueLowWatermark(mamaLowWaterMark); } catch (Exception e) { Console.WriteLine("Could not set default queue low water mark MamaStatus: " + e); } } } // create the transport mamaTransport = new MamaTransport(); mamaTransport.setTransportCallback(this); // the default throttle rate is 500 msg/sec if (mamaThrottle != -1) { mamaTransport.setOutboundThrottle(MamaTransport.MamaThrottleInstance.MAMA_THROTTLE_DEFAULT, mamaThrottle); } // the default recap throttle rate is 250 msg/sec if (mamaRecapThrottle != -1) { mamaTransport.setOutboundThrottle(MamaTransport.MamaThrottleInstance.MAMA_THROTTLE_RECAP, mamaRecapThrottle); } mamaTransport.create(mamaTransportName, mamaBridge); // create default queue and, if required, queue group createQueues(); mamaDictionarySource = new MamaSource(); mamaDictionarySource.symbolNamespace = mamaDictionarySourceName; mamaDictionarySource.transport = mamaTransport; // download dictionary mamaDictionary = new MamaDictionary(); mamaDictionary.create( mamaDefaultQueue, this, mamaDictionarySource, 3, 10.0f); loadSymbolMap(); Mama.start(mamaBridge); if (!dictionaryComplete) { throw new Exception("Can't create dictionary."); } }
private void InitializeMama() { try { Mama.logToFile(@"mama.log", MamaLogLevel.MAMA_LOG_LEVEL_FINEST); bridge = new MamaBridge(middlewareName); Mama.open(); transport = new MamaTransport(); transport.create(transportName, bridge); defaultQueue = Mama.getDefaultEventQueue(bridge); } catch (MamaException e) { Console.WriteLine("Error initializing mama or creating transport: {0}", e.ToString()); Exit(1); } }
public int Run() { ParseArgs(); if (helpNeeded) { DisplayUsage(); return 0; } Mama.logToFile(@"mama.log", MamaLogLevel.MAMA_LOG_LEVEL_FINEST); bridge = Mama.loadBridge(middlewareName); Mama.open(); MamaTransport transport = new MamaTransport(); MamaQueue defaultQueue = Mama.getDefaultEventQueue(bridge); MamaTimer timer = new MamaTimer(); MamaSubscription subscription = new MamaSubscription(); MamaPublisherCS publisher = this; transport.create(transportName, bridge); timer.create(defaultQueue, publisher, interval, null); subscription.createBasic(transport, defaultQueue, publisher, inboundTopic); publisher.create(transport, outboundTopic); msg = new MamaMsg(); Mama.start(bridge); Mama.close(); return 0; }