open() public static method

Initialize MAMA. MAMA employs a reference count to track multiple calls to Mama.open() and Mama.close(). The count is incremented every time Mama.open() is called and decremented when Mama.close() is called. The resources are not actually released until the count reaches zero. If entitlements are enabled for the library, the available entitlement server names are read from the entitlement.servers property in the mama.properties file located in the %WOMBAT_PATH% directory. This function is thread safe.
public static open ( ) : void
return void
コード例 #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
        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);
            }
        }
コード例 #3
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);
        }
コード例 #4
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);
        }
コード例 #5
0
ファイル: MamaIoCS.cs プロジェクト: vitya-maleyev/OpenMAMA
 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);
     }
 }
コード例 #6
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);
     }
 }
コード例 #7
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;
            }
        }