Beispiel #1
0
        static void Main(string[] args)
        {
            TMParser parser = new TMParser();

            if (!parser.Parse(args))
            {
                return;
            }

            var serverProv = new SoapServerFormatterSinkProvider {
                TypeFilterLevel = TypeFilterLevel.Full
            };

            var clientProv = new SoapClientFormatterSinkProvider();

            IDictionary props = new Hashtable();

            props["port"] = Int32.Parse(parser["p"]);

            var channel = new HttpChannel(props, clientProv, serverProv);

            ChannelServices.RegisterChannel(channel, false);

            RemotingConfiguration.RegisterWellKnownServiceType
                (Type.GetType("MyTM.MyTM")                              // full type name
                , "TM.soap"                                             // URI
                , System.Runtime.Remoting.WellKnownObjectMode.Singleton // instancing mode
                );

            while (true)
            {
                Thread.Sleep(2000);
                TwoPhaseCommit.PrintMessage();
            }
        }
Beispiel #2
0
        static void Main(string[] args)
        {
            TMParser parser = new TMParser();

            if (!parser.Parse(args))
            {
                return;
            }

            SoapServerFormatterSinkProvider serverProv = new SoapServerFormatterSinkProvider();

            serverProv.TypeFilterLevel = TypeFilterLevel.Full;

            SoapClientFormatterSinkProvider clientProv = new SoapClientFormatterSinkProvider();

            IDictionary props = new Hashtable();

            props["port"] = Int32.Parse(parser["p"]);

            HttpChannel channel = new HttpChannel(props, clientProv, serverProv);

            ChannelServices.RegisterChannel(channel, false);

            RemotingConfiguration.RegisterWellKnownServiceType
                (Type.GetType("MyTM.MyTM")                                      // full type name
                , "TM.soap"                                                     // URI
                , System.Runtime.Remoting.WellKnownObjectMode.Singleton         // instancing mode
                );

            // activate the object
            string[] urls = channel.GetUrlsForUri("TM.soap");
            if (1 != urls.Length)
            {
                throw new InvalidOperationException();
            }

            MyTM transactionManager = (MyTM)System.Activator.GetObject(typeof(TP.TM), urls[0]);

            if (null == transactionManager)
            {
                throw new InvalidProgramException();
            }

            // Do recovery every 30 seconds to recommit/reabort unacknowledged transactions
            // as well as doing garbage collection on the outstanding transaction file
            while (true)
            {
                Console.WriteLine("Recovery will run in 30 seconds...");
                System.Threading.Thread.Sleep(30000);
                transactionManager.recovery();
            }
        }
Beispiel #3
0
        static void Main(string[] args)
        {
            TMParser parser = new TMParser();
            if (!parser.Parse(args))
            {
                return;
            }

            var serverProv = new SoapServerFormatterSinkProvider { TypeFilterLevel = TypeFilterLevel.Full };

            var clientProv = new SoapClientFormatterSinkProvider();

            IDictionary props = new Hashtable();
            props["port"] = Int32.Parse(parser["p"]);

            var channel = new HttpChannel(props, clientProv, serverProv);
            ChannelServices.RegisterChannel(channel, false);

            RemotingConfiguration.RegisterWellKnownServiceType
                (Type.GetType("MyTM.MyTM")  // full type name
                        , "TM.soap"         // URI
                        , System.Runtime.Remoting.WellKnownObjectMode.Singleton	// instancing mode
                );

            while (true)
            {
                Thread.Sleep(2000);
                TwoPhaseCommit.PrintMessage();
            }
        }