MAMA - Middleware Agnostic Messaging API
MAMA provides an abstraction layer over various messaging middleware platforms. In particular, MAMA adds market data semantics to messaging platforms that would otherwise be too limited for use as a market data distribution middleware. Features that MAMA adds to any messaging middleware are: Subscription management (initial values, throttling). Entitlements/permissioning. Data quality. MAMA currently supports the following middleware platforms: Wombat TCP Middleware 29West Latency Busters Messaging (see http://29west.com) Tibco TIB/RV versions 6 and 7 (see http://tibco.com)

Future supported platforms may include: Tibco SmartSockets (see http://tibco.com) Reuters SSL, SFC, TibMsg, etc.

A higher level market data API is also available: the Middleware Agnostic Market Data API (MAMDA). While MAMA provides a field-based abstraction to market data, MAMDA provides smart, specialized data types to deal with specific market data events, such as trades, quotes, order books, etc. MAMDA is particularly suitable for applications such as program trading and tick capture systems, where context is important. MAMA is more suited to applications that don't care about the meaning of fields, such as a simple, field-based market data display application.

Пример #1
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);
        }
Пример #2
0
            public override void onIo(MamaIo io, mamaIoType ioType)
            {
                Socket sock = example_.client;

                byte [] buffer = new byte[1024];
                int     len    = sock.Receive(buffer, 1023, SocketFlags.None);

                buffer[len] = (byte)'\0';

                string text = Encoding.ASCII.GetString(buffer, 0, len);

                if (!example_.quiet)
                {
                    Console.WriteLine("READ: {0}", text);
                }

                // should test for "quit", but Windows' telnet client won't send it
                // no matter if "set mode stream" was used and would send only partial
                // substrings, such as "q", then "uit", "qu", then "it", etc.
                if (text.StartsWith("q"))
                {
                    Console.WriteLine("QUITING");
                    Mama.stop(MamaIoCS.bridge);
                    return;
                }

                sock.Send(buffer, len, SocketFlags.None);
            }
Пример #3
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);
            }
        }
Пример #4
0
        private MamaMultiSubscriberCS(string[] args)
        {
            try
            {
                if (parseCommandLine(args))
                {
                    IEnumerator iterator = middlewareNames.GetEnumerator();

                    while (iterator.MoveNext())
                    {
                        MamaBridge bridge = Mama.loadBridge((string)iterator.Current);
                        mamaBridges.Add(bridge);
                    }

                    Mama.open();

                    iterator = mamaBridges.GetEnumerator();

                    while (iterator.MoveNext())
                    {
                        createSubscriber((MamaBridge)iterator.Current);
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
        }
Пример #5
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();
        }
Пример #6
0
 public void init()
 {
     myDefaultQueue = Mama.getDefaultEventQueue(myBridge);
     myTimer.create(myDefaultQueue, this, 2.0, null);               // two seconds
     myFtMember.create();
     myFtMember.setup(myDefaultQueue, this, myTransport, myGroup, myWeight, 1.0, 6.0, null);
     myFtMember.activate();
 }
Пример #7
0
 public void onTimer(MamaTimer mamaTimer, object closure)
 {
     Publish(null);
     if (messageCount_ > 0 && --messageCount_ == 0)
     {
         Mama.stop(bridge);
         return;
     }
 }
Пример #8
0
 // Timer Callbacks
 public void onTimer(MamaTimer mamaTimer, object closure)
 {
     Publish(null);
     if (messageCount > 0 && --messageCount <= 0)
     {
         publisher.destroy();
         System.Threading.Thread.Sleep(1000);                                    // let queued events process
         Mama.stop(bridge);
     }
 }
Пример #9
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);
        }
Пример #10
0
 private void InitializeMama()
 {
     try
     {
         Mama.logToFile(@"mama.log", MamaLogLevel.MAMA_LOG_LEVEL_FINEST);
         bridge = Mama.loadBridge(middleware);
         Mama.open();
         defaultQueue = Mama.getDefaultEventQueue(bridge);
     }
     catch (MamaException e)
     {
         Console.WriteLine("Error initializing mama: {0}", e.ToString());
         Exit(1);
     }
 }
Пример #11
0
        static void Main(string[] args)
        {
            try
            {
                MamaFtMemberCS ftDemo = new MamaFtMemberCS();
                ftDemo.parseCommandLine(args);

                ftDemo.init();

                Mama.start(ftDemo.myBridge);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
        }
Пример #12
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);
     }
 }
Пример #13
0
        private static void onDestroy(IntPtr nativeHandle, IntPtr closure)
        {
            // Obtain the handle from the closure
            GCHandle handle = (GCHandle)closure;

            // Extract the impl from the handle
            MamaPublisher pub = (MamaPublisher)handle.Target;

            Mama.log(MamaLogLevel.MAMA_LOG_LEVEL_FINE, "DotNet.onDestroy: pub=" + pub);

            // Use the impl to invoke the error callback
            if (null != pub)
            {
                // Invoke the callback
                pub.mCallback.onDestroy(pub);
                handle.Free();
            }
            pub.NativeHandle = IntPtr.Zero;
        }
Пример #14
0
        /// <summary>
        /// This function will store the supplied wrapper and return an object
        /// that can be passed into the native layer as a closure.
        /// This should then be passed to the RemoveWrapper function to access
        /// the object whenever the native callback is invoked.
        /// </summary>
        /// <param name="wrapper">
        /// The wrapper object to store.
        /// </param>
        /// <returns>
        /// The handle that can be passed to the native layer.
        /// </returns>
        internal IntPtr StoreWrapper(MamaCallbackWrapper <TCallback, TDelegate> wrapper)
        {
            // Returns
            long ret = 0;

            // Acquire the mutex
            mStoreMutex.WaitOne();
            try
            {
                // Get the next Id
                mNextId++;

                // This will become the handle
                ret = mNextId;

                // Add the wrapper to the store using the Id as the key
                mStore.Add(ret, wrapper);
            }

            finally
            {
                // Release the mutex
                mStoreMutex.ReleaseMutex();
            }

            // Write a log
            if (MamaLogLevel.MAMA_LOG_LEVEL_FINEST == Mama.getLogLevel())
            {
                // Write details of the object that has bee added
                string message = string.Format("MamaCallbackStore: Wrapper stored for key {0} for callback {1}.", ret, wrapper.Callback.ToString());
                Mama.log(MamaLogLevel.MAMA_LOG_LEVEL_FINEST, message);

                // Write the number of items
                message = string.Format("MamaCallbackStore: Store now contains {0} items.", mStore.Count);
                Mama.log(MamaLogLevel.MAMA_LOG_LEVEL_FINEST, message);
            }

            /* Return the next Id as the handle. */
            return(new IntPtr(ret));
        }
Пример #15
0
        /// <summary>
        /// This function will remove a wrapper object from the store and return it
        /// to the caller. This object should then be disposed by the caller.
        /// </summary>
        /// <param name="handle">
        /// Handle returned from the StoreWrapper function.
        /// </param>
        /// <returns>
        /// The callback wrapper associated with the supplied handle.
        /// </returns>
        /// <exception cref="ArgumentOutOfRangeException">
        /// Thrown if the corresponding wrapper is not in the store.
        /// </exception>
        internal MamaCallbackWrapper <TCallback, TDelegate> RemoveWrapper(IntPtr handle)
        {
            // Returns
            MamaCallbackWrapper <TCallback, TDelegate> ret = null;

            // The object handle is the key
            long key = handle.ToInt64();

            // Acquire the mutex
            mStoreMutex.WaitOne();
            try
            {
                // Get the wrapper from the store
                ret = mStore[key];

                // Remove the object from the store
                mStore.Remove(key);
            }

            finally
            {
                // Release the mutex
                mStoreMutex.ReleaseMutex();
            }

            // Write a log
            if (MamaLogLevel.MAMA_LOG_LEVEL_FINEST == Mama.getLogLevel())
            {
                // Write details of the object that has been removed
                string message = string.Format("MamaCallbackStore: Wrapper removed for key {0} for callback {1}.", key, ret.Callback.ToString());
                Mama.log(MamaLogLevel.MAMA_LOG_LEVEL_FINEST, message);

                // Write the number of items
                message = string.Format("MamaCallbackStore: Store now contains {0} items.", mStore.Count);
                Mama.log(MamaLogLevel.MAMA_LOG_LEVEL_FINEST, message);
            }

            return(ret);
        }
Пример #16
0
        public int Run()
        {
            ParseArgs();
            if (helpNeeded)
            {
                DisplayUsage();
                return(0);
            }

            InitializeMama();
            CreatePublisher();
            CreateInbox();

            for (int i = 0; i < 1000; ++i)
            {
                SendRequest();
            }

            Mama.start(bridge);

            return(0);
        }
Пример #17
0
        public int Run()
        {
            ParseArgs();
            if (helpNeeded)
            {
                DisplayUsage();
                return(0);
            }

            InitializeMama();
            WaitForConnection();
            CreateIoHandlers();

            Mama.start(bridge);

            readHandler.destroy();
            writeHandler.destroy();
            exceptHandler.destroy();

            client.Shutdown(SocketShutdown.Both);
            client.Close();

            return(0);
        }
Пример #18
0
        private bool parseCommandLine(string[] args)
        {
            for (int i = 0; i < args.Length; i++)
            {
                if (args[i].CompareTo("-s") == 0)
                {
                    if ((i + 1) < args.Length)
                    {
                        topicName = args[++i];
                        continue;
                    }
                }

                if (args[i].CompareTo("-m") == 0)
                {
                    if ((i + 1) < args.Length)
                    {
                        middlewareNames.Add(args[++i]);
                        continue;
                    }
                }

                if (args[i].CompareTo("-tport") == 0)
                {
                    if ((i + 1) < args.Length)
                    {
                        transportName = args[++i];
                        continue;
                    }
                }

                if (args[i].CompareTo("--help") == 0)
                {
                    Console.WriteLine(usage);
                    return(false);
                }

                if (args[i].CompareTo("-?") == 0)
                {
                    Console.WriteLine(usage);
                    return(false);
                }

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

                Console.WriteLine("Error: unrecognized parameter: " + args[i]);
                return(false);
            }

            return(true);
        }
Пример #19
0
 public void dispatch()
 {
     Mama.start(myBridge);
 }
Пример #20
0
        private void ParseArgs()
        {
            for (int i = 0; i < args.Length;)
            {
                string arg = args[i];
                if (arg[0] != '-')
                {
                    Console.WriteLine("Ignoring invalid argument {0}", arg);
                    ++i;
                    continue;
                }
                string opt = arg.Substring(1);
                switch (opt)
                {
                case "s":
                    if ((i + 1) == args.Length)
                    {
                        Console.WriteLine("Expecting inbound topic name after {0}", arg);
                        ++i;
                        continue;
                    }
                    inboundTopic = args[++i];
                    break;

                case "h":
                case "?":
                    helpNeeded = true;
                    return;

                case "m":
                    if ((i + 1) == args.Length)
                    {
                        Console.WriteLine("Expecting middleware name after {0}", arg);
                        ++i;
                        continue;
                    }
                    middlewareName = args[++i];
                    break;

                case "tport":
                    if ((i + 1) == args.Length)
                    {
                        Console.WriteLine("Expecting transport name after {0}", arg);
                        ++i;
                        continue;
                    }
                    transportName = args[++i];
                    break;

                case "q":
                    quiet = true;
                    break;

                case "v":
                    if (logLevel == MamaLogLevel.MAMA_LOG_LEVEL_WARN)
                    {
                        logLevel = MamaLogLevel.MAMA_LOG_LEVEL_NORMAL;
                        Mama.enableLogging(logLevel);
                    }
                    else if (logLevel == MamaLogLevel.MAMA_LOG_LEVEL_NORMAL)
                    {
                        logLevel = MamaLogLevel.MAMA_LOG_LEVEL_FINE;
                        Mama.enableLogging(logLevel);
                    }
                    else if (logLevel == MamaLogLevel.MAMA_LOG_LEVEL_FINE)
                    {
                        logLevel = MamaLogLevel.MAMA_LOG_LEVEL_FINER;
                        Mama.enableLogging(logLevel);
                    }
                    else
                    {
                        logLevel = MamaLogLevel.MAMA_LOG_LEVEL_FINEST;
                        Mama.enableLogging(logLevel);
                    }
                    break;

                default:
                    Console.WriteLine("Ignoring invalid option {0}", arg);
                    break;
                }
                ++i;
            }

            if (!quiet)
            {
                Console.WriteLine("Starting Publisher with:\n" +
                                  "   topic:              {0}\n" +
                                  "   transport:          {1}\n",
                                  inboundTopic,
                                  transportName);
            }
        }
Пример #21
0
        private void ParseArgs()
        {
            for (int i = 0; i < args.Length;)
            {
                string arg = args[i];
                if (arg[0] != '-')
                {
                    Console.WriteLine("Ignoring invalid argument {0}", arg);
                    ++i;
                    continue;
                }
                string opt = arg.Substring(1);
                switch (opt)
                {
                case "m":
                case "middleware":
                    if ((i + 1) == args.Length)
                    {
                        Console.WriteLine("Expecting name after {0}", arg);
                        ++i;
                        continue;
                    }
                    middleware = args[++i];
                    break;

                case "p":
                case "port":
                    if ((i + 1) == args.Length)
                    {
                        Console.WriteLine("Expecting port after {0}", arg);
                        ++i;
                        continue;
                    }
                    try
                    {
                        port = int.Parse(args[++i], NumberStyles.Integer, CultureInfo.InvariantCulture);
                    }
                    catch                             // ignore parse error
                    {
                    }
                    break;

                case "h":
                case "?":
                    helpNeeded = true;
                    return;

                case "q":
                    quiet = true;
                    break;

                case "v":
                    if (logLevel == MamaLogLevel.MAMA_LOG_LEVEL_WARN)
                    {
                        logLevel = MamaLogLevel.MAMA_LOG_LEVEL_NORMAL;
                        Mama.enableLogging(logLevel);
                    }
                    else if (logLevel == MamaLogLevel.MAMA_LOG_LEVEL_NORMAL)
                    {
                        logLevel = MamaLogLevel.MAMA_LOG_LEVEL_FINE;
                        Mama.enableLogging(logLevel);
                    }
                    else if (logLevel == MamaLogLevel.MAMA_LOG_LEVEL_FINE)
                    {
                        logLevel = MamaLogLevel.MAMA_LOG_LEVEL_FINER;
                        Mama.enableLogging(logLevel);
                    }
                    else
                    {
                        logLevel = MamaLogLevel.MAMA_LOG_LEVEL_FINEST;
                        Mama.enableLogging(logLevel);
                    }
                    break;

                default:
                    Console.WriteLine("Ignoring invalid option {0}", arg);
                    break;
                }
                ++i;
            }

            if (!quiet)
            {
                Console.WriteLine("Starting IO with:\n" +
                                  "   port:               {0}", port);
            }
        }
Пример #22
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;
            }
        }
Пример #23
0
        private void ParseArgs()
        {
            for (int i = 0; i < args.Length;)
            {
                string arg = args[i];
                if (arg[0] != '-')
                {
                    Console.WriteLine("Ignoring invalid argument {0}", arg);
                    ++i;
                    continue;
                }
                string opt = arg.Substring(1);
                switch (opt)
                {
                case "s":
                    if ((i + 1) == args.Length)
                    {
                        Console.WriteLine("Expecting outbound topic name after {0}", arg);
                        ++i;
                        continue;
                    }
                    outboundTopic = args[++i];
                    break;

                case "l":
                    if ((i + 1) == args.Length)
                    {
                        Console.WriteLine("Expecting inbound topic name after {0}", arg);
                        ++i;
                        continue;
                    }
                    inboundTopic = args[++i];
                    break;

                case "nosub":
                    nosub = true;
                    break;

                case "c":
                    if ((i + 1) == args.Length)
                    {
                        Console.WriteLine("Expecting message count after {0}", arg);
                        ++i;
                        continue;
                    }
                    try
                    {
                        messageCount = int.Parse(args[++i], NumberStyles.Integer, CultureInfo.InvariantCulture);
                    }
                    catch     // ignore parse error
                    {
                    }
                    break;

                case "i":
                    if ((i + 1) == args.Length)
                    {
                        Console.WriteLine("Expecting interval after {0}", arg);
                        ++i;
                        continue;
                    }
                    double.TryParse(args[++i], NumberStyles.Float, CultureInfo.InvariantCulture, out interval);
                    break;

                case "h":
                case "?":
                    helpNeeded = true;
                    return;

                case "m":
                    if ((i + 1) == args.Length)
                    {
                        Console.WriteLine("Expected middleware name after {0}", arg);
                        ++i;
                        continue;
                    }
                    middlewareName = args[++i];
                    break;

                case "tport":
                    if ((i + 1) == args.Length)
                    {
                        Console.WriteLine("Expecting transport name after {0}", arg);
                        ++i;
                        continue;
                    }
                    transportName = args[++i];
                    break;

                case "q":
                    quiet = true;
                    break;

                case "pubCb":
                    pubCb = true;
                    break;

                case "v":
                    if (logLevel == MamaLogLevel.MAMA_LOG_LEVEL_WARN)
                    {
                        logLevel = MamaLogLevel.MAMA_LOG_LEVEL_NORMAL;
                        Mama.enableLogging(logLevel);
                    }
                    else if (logLevel == MamaLogLevel.MAMA_LOG_LEVEL_NORMAL)
                    {
                        logLevel = MamaLogLevel.MAMA_LOG_LEVEL_FINE;
                        Mama.enableLogging(logLevel);
                    }
                    else if (logLevel == MamaLogLevel.MAMA_LOG_LEVEL_FINE)
                    {
                        logLevel = MamaLogLevel.MAMA_LOG_LEVEL_FINER;
                        Mama.enableLogging(logLevel);
                    }
                    else
                    {
                        logLevel = MamaLogLevel.MAMA_LOG_LEVEL_FINEST;
                        Mama.enableLogging(logLevel);
                    }
                    break;

                default:
                    Console.WriteLine("Ignoring invalid option {0}", arg);
                    break;
                }
                ++i;
            }

            Console.WriteLine("Starting Publisher with:\n" +
                              "   topic:              {0}\n" +
                              "   inbound topic:      {1}\n" +
                              "   interval            {2}\n" +
                              "   middleware          {3}\n" +
                              "   transport:          {4}\n",
                              outboundTopic, inboundTopic, interval, middlewareName, transportName);
        }