The underpinning object in any MAMA application
The mamaTransport defines the network protocol level parameters over which MAMA distributes data. Transports effectively provide scope for data identifying the underlying protocols and their values for data delivery. It is an isolated communication channel for data traffic. Transports specify the communication channels to use for making subscriptions and publishing data through the API.
Наследование: MamaWrapper
Пример #1
0
        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);
            }
        }
Пример #2
0
        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;
        }
Пример #3
0
 public MamaFtMemberCS()
 {
     myState = mamaFtState.MAMA_FT_STATE_UNKNOWN;
     myTransport = null;
     myWeight = 50;
     myGroup = null;
 }
Пример #4
0
		/// <summary>
		/// Create and activate a subscription.
		/// Any properties for the subscription should be set prior to
		/// calling this method.
		/// </summary>
		/// <param name="transport"></param>
		/// <param name="queue"></param>
		/// <param name="source"></param>
		/// <param name="symbol"></param>
		/// <param name="closure"></param>
		public void create(
			MamaTransport         transport,
			MamaQueue             queue,
			string                source,
			string                symbol,
			object                closure)
		{
			setSource(source);
			setSymbol(symbol);
			setTransport(transport);
			setQueue(queue);
			setClosure(closure);
			activate();
		}
Пример #5
0
        /// <summary>
        /// </summary>
        /// <param name="transport"></param>
        /// <param name="queue"></param>
        /// <param name="handler"></param>
        /// <param name="source"></param>
        /// <param name="symbol"></param>
        /// <param name="intervalSeconds"></param>
        public MamdaOrderBookChecker(
			MamaTransport transport,
			MamaQueue queue,
			MamdaOrderBookCheckerHandler handler,
			string source,
			string symbol,
			double intervalSeconds)
        {
            mSnapShotmHandler = new SnapShotChecker(this);
            mRealTimeSubsc = new MamdaSubscription();
            mRealTimeListener = new MamdaOrderBookListener();
            mHandler = handler;
            mQueue = queue;
            mIntervalSecs = intervalSeconds;
            mRandomTimerFired = false;
            mRealTimeSubsc.setType(mamaSubscriptionType.MAMA_SUBSC_TYPE_BOOK);
            mRealTimeSubsc.create(transport, queue, source, symbol, null);
            mRealTimeSubsc.addMsgListener(mRealTimeListener);
            init();
        }
Пример #6
0
		protected void setupFtType(
			mamaFtType ftType,
			MamaQueue queue,
			MamaFtMemberCallback callback,
			MamaTransport transport,
			string groupName,
			uint weight,
			double heartbeatInterval,
			double timeoutInterval,
			object closure)
		{
			EnsurePeerCreated();
			if (callback == null)
			{
				mCallbackForwarder = null;
				mCallback = null;
			}
			else
			{
				mCallbackForwarder = new CallbackForwarder(this, callback, closure);
				mCallback = new CallbackForwarder.FtMemberCallbackDelegate(mCallbackForwarder.OnFtStateChange);
			}
			IntPtr queueHandle = queue != null ? queue.NativeHandle : IntPtr.Zero;
			IntPtr transportHandle = transport != null ? transport.NativeHandle : IntPtr.Zero;
			int code = NativeMethods.mamaFtMember_setup(
				nativeHandle,
				mamaFtType.MAMA_FT_TYPE_MULTICAST,
				queueHandle,
				mCallback,
				transportHandle,
				groupName,
				weight,
				heartbeatInterval,
				timeoutInterval,
				null);
			CheckResultCode(code);
		}
Пример #7
0
 public void onReconnect(MamaTransport transport)
 {
     Console.WriteLine("Transport Reconnected.");
 }
Пример #8
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();
		}
Пример #9
0
        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;
            }
        }
Пример #10
0
        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;
            }
        }
Пример #11
0
 public void onNamingServiceDisconnect(MamaTransport transport)
 {
     Console.WriteLine("Transport Naming Service Disconnected.");
 }
Пример #12
0
 public void onConnect(MamaTransport transport)
 {
     Console.WriteLine("Transport Connect");
 }
Пример #13
0
		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;
		}
Пример #14
0
        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;
            }
        }
Пример #15
0
 public CallbackForwarderSymbolMap(MamaTransport sender, MamaSymbolMapCallback callback, object closure)
 {
     mCallback = callback;
     mClosure  = closure;
 }
Пример #16
0
 public CallbackForwarder(MamaTransport target, MamaTransportCallback callback)
 {
     this.mTarget   = target;
     this.mCallback = callback;
 }
Пример #17
0
 /// <summary>
 /// This function will create the basic subscription without marketdata semantics.
 /// This overload provides access to the basic subscription with the MamaSubscriptionCallback rather than the
 /// MamaBasicSubscriptionCallback interface.
 /// Instantiating the base class directly will provide better performance.
 /// </summary>
 /// <param name="transport">
 /// The MamaTransport.
 /// </param>
 /// <param name="queue">
 /// The MamaQueue.
 /// </param>
 /// <param name="callback">
 /// Provide callback function implementations to be informed of events on the subscription.
 /// </param>
 /// <param name="symbol">
 /// The symbol to subscribe to.
 /// </param>
 /// <param name="closure">
 /// The closure that will be passed back with the callback functions.
 /// </param>
 public void createBasic(MamaTransport transport, MamaQueue queue, MamaSubscriptionCallback callback, string symbol, object closure)
 {
     // Call the base class using the adapter to convert between the callback types
     base.createBasic(transport, queue, new MamaBasicCallbackAdapter(callback), symbol, closure);
 }
Пример #18
0
 /// <summary>
 /// This function will create the basic subscription without marketdata semantics.
 /// To pass a closure use the overload.
 /// This overload provides access to the basic subscription with the MamaSubscriptionCallback rather than the
 /// MamaBasicSubscriptionCallback interface.
 /// Instantiating the base class directly will provide better performance.
 /// </summary>
 /// <param name="transport">
 /// The MamaTransport.
 /// </param>
 /// <param name="queue">
 /// The MamaQueue.
 /// </param>
 /// <param name="callback">
 /// Provide callback function implementations to be informed of events on the subscription.
 /// </param>
 /// <param name="symbol">
 /// The symbol to subscribe to.
 /// </param>
 public void createBasic(MamaTransport transport, MamaQueue queue, MamaSubscriptionCallback callback, string symbol)
 {
     // Call the overload
     createBasic(transport, queue, callback, symbol, null);
 }
Пример #19
0
 public void onConnect(MamaTransport transport)
 {
     Console.WriteLine("Transport Connect");
 }
Пример #20
0
		public void setup(
			MamaQueue queue,
			MamaFtMemberCallback callback,
			MamaTransport transport,
			string groupName,
			uint weight,
			double heartbeatInterval,
			double timeoutInterval,
			object closure)
		{
			setupFtType (
				mamaFtType.MAMA_FT_TYPE_MULTICAST,
				queue,
				callback,
				transport,
				groupName,
				weight,
				heartbeatInterval,
				timeoutInterval,
				closure);
		}
Пример #21
0
 public CallbackForwarderSymbolMap(MamaTransport sender, MamaSymbolMapCallback callback, object closure)
 {
     mCallback = callback;
     mClosure = closure;
 }
Пример #22
0
        /// <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();
        }
Пример #23
0
 public TopicCallbackForwarder(MamaTransport target, MamaTransportTopicCallback callback)
 {
     this.mTarget = target;
     this.mCallback = callback;
 }
Пример #24
0
 /// <summary>
 /// Set the MAMA transport.  Do this before calling activate().
 /// </summary>
 /// <param name="transport"></param>
 public void setTransport(MamaTransport transport)
 {
     mTransport = transport;
 }
Пример #25
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);
			}
		}
Пример #26
0
        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);
            }
        }
Пример #27
0
		/// <summary>
		/// Create a mama publisher for the corresponding transport. If the transport
		/// is a marketdata transport, as opposed to a "basic" transport, the topic
		/// corresponds to the symbol. For a basic transport, the source and root get 
		/// ignored.
		/// </summary>
		/// <param name="transport">The transport.</param>
		/// <param name="topic">Symbol on which to publish.</param>
		/// <param name="source">The source for market data publishers. (e.g. source.symbol)</param>
		/// <param name="root">The root for market data publishers. Used internally.</param>
		public void create(
			MamaTransport transport,
			string topic,
			string source,
			string root)
		{
#if MAMA_WRAPPERS_CHECK_ARGUMENTS
			if (transport == null)
			{
				throw new ArgumentNullException("transport");
			}
			if (topic == null)
			{
				throw new ArgumentNullException("topic");
			}
			if (nativeHandle != IntPtr.Zero)
			{
				throw new InvalidOperationException("MamaPublisher already created");
			}
#endif // MAMA_WRAPPERS_CHECK_ARGUMENTS
			
			int code = NativeMethods.mamaPublisher_create(ref nativeHandle, transport.NativeHandle, topic, source, root);
			CheckResultCode(code);
			GC.KeepAlive(transport);
		}
Пример #28
0
		/// <summary>
		/// Create a mama publisher for the corresponding transport. If the transport
		/// is a marketdata transport, as opposed to a "basic" transport, the topic
		/// corresponds to the symbol. For a basic transport, the source and root get 
		/// ignored.
		/// </summary>
		/// <param name="transport">The transport.</param>
		/// <param name="topic">Symbol on which to publish.</param>
		public void create(
			MamaTransport transport,
			string topic)
		{
			create(transport, topic, null, null);
		}
Пример #29
0
        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;
        }
Пример #30
0
		/// <summary>
		/// Create a mama publisher for the corresponding transport. If the transport
		/// is a marketdata transport, as opposed to a "basic" transport, the topic
		/// corresponds to the symbol. For a basic transport, the source and root get 
		/// ignored.
		/// </summary>
		/// <param name="transport">The transport.</param>
		/// <param name="topic">Symbol on which to publish.</param>
		/// <param name="source">The source for market data publishers. (e.g. source.symbol)</param>
		public void create(
			MamaTransport transport,
			string topic,
			string source)
		{
			create(transport, topic, source, null);
		}
Пример #31
0
		/// <summary>
		/// Set the MAMA transport.  Do this before calling activate().
		/// </summary>
		/// <param name="transport"></param>
		public void setTransport(MamaTransport transport)
		{
			mTransport = transport;
		}
Пример #32
0
 /// <summary>
 /// Create a mama publisher for the corresponding transport. If the transport
 /// is a marketdata transport, as opposed to a "basic" transport, the topic
 /// corresponds to the symbol. For a basic transport, the source and root get
 /// ignored.
 /// </summary>
 /// <param name="transport">The transport.</param>
 /// <param name="topic">Symbol on which to publish.</param>
 public void create(
     MamaTransport transport,
     string topic)
 {
     create(transport, topic, null, null);
 }
Пример #33
0
 /// <summary>
 /// Creates an inbox and stores at the address specified by the calling client.
 /// </summary>
 /// <param name="transport">
 /// The mamaTransport being used.
 /// </param>
 /// <param name="queue">
 /// Optional mamaQueue. Will use default queue if null.
 /// </param>
 /// <param name="callback">
 /// A callback interface invoked in response to a p2p message being received or when an error is
 /// encountered during p2p messaging.
 /// </param>
 public void create(MamaTransport transport, MamaQueue queue, MamaInboxCallback callback)
 {
     create(transport, queue, callback, null);
 }
Пример #34
0
        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.");
            }

        }
Пример #35
0
 /// <summary>
 /// Creates an inbox and stores at the address specified by the calling client.
 /// Uses a default queue.
 /// This functionality is no longer supported.
 /// </summary>
 /// <param name="transport">
 /// The mamaTransport being used.
 /// </param>
 /// <param name="callback">
 /// A callback interface invoked in response to a p2p message being received or hen an error is
 /// encountered during p2p messaging.
 /// </param>
 /// <param name="closure">
 /// User supplied data.
 /// </param>
 public void create(MamaTransport transport, MamaInboxCallback callback, object closure)
 {
     throw new NotSupportedException("This function is no longer supported, use an overload that takes a MamaQueue object.");
 }
Пример #36
0
 public void onQuality(MamaTransport transport)
 {
     Console.WriteLine("Transport Quality.");
 }
Пример #37
0
 public void onPublisherDisconnect(MamaTransport transport)
 {
     Console.WriteLine("Transport Publisher disconnected.");
 }
Пример #38
0
 public void onAcceptReconnect(MamaTransport transport)
 {
     Console.WriteLine("Transport Accept Reconnect.");
 }
Пример #39
0
 public void onReconnect(MamaTransport transport)
 {
     Console.WriteLine("Transport Reconnected.");
 }
Пример #40
0
 public void onNamingServiceDisconnect(MamaTransport transport)
 {
     Console.WriteLine("Transport Naming Service Disconnected.");
 }
Пример #41
0
        /// <summary>
        /// Create a mama publisher for the corresponding transport. If the transport
        /// is a marketdata transport, as opposed to a "basic" transport, the topic
        /// corresponds to the symbol. For a basic transport, the source and root get 
        /// ignored.
        /// </summary>
        /// <param name="transport">The transport.</param>
        /// <param name="topic">Symbol on which to publish.</param>
        /// <param name="source">The source for market data publishers. (e.g. source.symbol)</param>
        /// <param name="root">The root for market data publishers. Used internally.</param>
        public void createWithCallbacks(
            MamaTransport transport,
            MamaQueue queue,
            MamaPublisherCallback callback,
            Object closure,
            string topic,
            string source,
            string root)
        {
            #if MAMA_WRAPPERS_CHECK_ARGUMENTS
            if (transport == null)
            {
                throw new ArgumentNullException("transport");
            }
            if (topic == null)
            {
                throw new ArgumentNullException("topic");
            }
            if (queue == null)
            {
                throw new ArgumentNullException("queue");
            }
            if (callback == null)
            {
                throw new ArgumentNullException("callback");
            }
            if (nativeHandle != IntPtr.Zero)
            {
                throw new InvalidOperationException("MamaPublisher already created");
            }
            #endif // MAMA_WRAPPERS_CHECK_ARGUMENTS
            mCallback = callback;

            GCHandle handle = GCHandle.Alloc(this);

            int code = NativeMethods.mamaPublisher_createWithCallbacks(
                ref nativeHandle,
                transport.NativeHandle,
                queue.NativeHandle,
                topic, source, root,
                ref mCallbackDelegates,
                (IntPtr)handle);
            CheckResultCode(code);

            GC.KeepAlive(transport);
            GC.KeepAlive(queue);
            GC.KeepAlive(callback);
        }
Пример #42
0
 public void onQuality(MamaTransport transport)
 {
     Console.WriteLine("Transport Quality.");
 }
Пример #43
0
        /// <summary>
        /// Get the MamaTransport.
        /// The result contains the reusable MamaTransport object of the
        /// nativeHandle object. Applications calling this method will receive the same
        /// reusable object for repeated calls on same nativeHandle object.
        /// </summary>
        public MamaTransport getTransport()
        {
            EnsurePeerCreated();
            IntPtr transport = IntPtr.Zero;
            int code = NativeMethods.mamaPublisher_getTransport(nativeHandle, ref transport);
            CheckResultCode(code);

            if (mReusableTransport == null)
            {
                mReusableTransport = new MamaTransport (transport);
            }
            else
            {
                mReusableTransport.setNativeHandle(transport);
            }
            return mReusableTransport;
        }
Пример #44
0
 public void onAcceptReconnect(MamaTransport transport)
 {
     Console.WriteLine("Transport Accept Reconnect.");
 }
Пример #45
0
 public void onPublisherDisconnect(MamaTransport transport)
 {
     Console.WriteLine("Transport Publisher disconnected.");
 }