Ejemplo n.º 1
0
        protected void StartUp(string url, string tmUrl)
        {
            if (string.Compare(tmUrl, "none", true) == 0)
            {
                return;
            }

            // Register with the TM
            while (transactionManager == null)
            {
                try
                {
                    this.transactionManager = (TP.TM)System.Activator.GetObject(typeof(TP.TM), tmUrl);

                    Transaction tid = this.transactionManager.Start();
                    this.transactionManager.Register(this.tmRegistrationString);
                    this.transactionManager.Abort(tid);
                }
                catch (Exception e)
                {
                    this.transactionManager = null;
                    Console.WriteLine(e.ToString());
                    Console.WriteLine("Waiting 1 second for Transaction Manager \"{0}\"", tmUrl);
                    System.Threading.Thread.Sleep(1000);
                }
            }
            Console.WriteLine("{0} RM: Transaction Manager retrieved at {1}", this.GetName(), tmUrl);

            // deal with prepared transactions
            this.ProcessPreparedTransactions();
        }
Ejemplo n.º 2
0
 public void Abort(Transaction context)
 {
     try
     {
         TransactionManager.Abort(context);
     }
     catch (WebException)
     {
         TransactionManager = null;
         ReconnectToTM();
     }
 }
Ejemplo n.º 3
0
 public void Abort(Transaction context)
 {
     try
     {
         TransactionManager.Abort(context);
     }
     catch (WebException)
     {
         TransactionManager = null;
         ReconnectToTM();
     }
 }
Ejemplo n.º 4
0
        public Transaction Start()
        {
            try
            {
                return(TransactionManager.Start());
            }
            catch (WebException)
            {
                TransactionManager = null;
                ReconnectToTM();
            }

            return(null);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// try to reconnect to TM after tm failed.
        /// </summary>
        public static void ReconnectToTM()
        {
            while (TransactionManager == null)
            {
                Console.WriteLine("Trying to reconnect to TM");
                TransactionManager = (TP.TM)Activator.GetObject(typeof(TP.TM), tmURL);
                try
                {
                    TransactionManager.Ping();
                }
                catch (WebException)
                {
                    TransactionManager = null;
                    Console.WriteLine("Waiting 1 second for Transaction Manager \"{0}\"", tmURL);
                    System.Threading.Thread.Sleep(1000);
                }
            }

            Console.WriteLine("Connected to Transaction Manager \"{0}\"", tmURL);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// try to reconnect to TM after tm failed. 
        /// </summary>
        public static void ReconnectToTM()
        {
            while (TransactionManager == null)
            {
                Console.WriteLine("Trying to reconnect to TM");
                TransactionManager = (TP.TM)Activator.GetObject(typeof(TP.TM), tmURL);
                try
                {
                    TransactionManager.Ping();
                }
                catch (WebException)
                {
                    TransactionManager = null;
                    Console.WriteLine("Waiting 1 second for Transaction Manager \"{0}\"", tmURL);
                    System.Threading.Thread.Sleep(1000);
                }
            }

            Console.WriteLine("Connected to Transaction Manager \"{0}\"", tmURL);
        }
Ejemplo n.º 7
0
        /// <summary>

        /*  WC runs as a separate process looping forever,
         *  waiting for the calls from other processes */
        /// </summary>
        static void Main(string[] args)
        {
            WCParser parser = new WCParser();

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

            //string rmFlightsURL = parser["f"];
            //string rmRoomsURL = parser["r"];
            //string rmCarsURL = parser["c"];
            string tmPort   = parser["tmp"];
            string tmServer = parser["tms"];
            string tmURL    = tmServer + ":" + tmPort + "/TM.soap";

            while (TransactionManager == null)
            {
                try
                {
                    TransactionManager = (TP.TM)Activator.GetObject(typeof(TP.TM), tmServer + ":" + tmPort + "/TM.soap");
                    Transaction tid = TransactionManager.Start();
                    TransactionManager.Abort(tid);
                }
                catch (RemotingException)
                {
                    TransactionManager = null;
                    Console.WriteLine("Waiting 1 second for Transaction Manager \"{0}\"", tmURL);
                    System.Threading.Thread.Sleep(1000);
                }
            }


            Console.WriteLine("Transaction Manager retrieved at {0}", tmURL);
            while (Flights == null || Rooms == null || Cars == null)
            {
                if (Flights == null)
                {
                    Flights = TransactionManager.GetResourceMananger("flight");
                }
                if (Rooms == null)
                {
                    Rooms = TransactionManager.GetResourceMananger("room");
                }
                if (Cars == null)
                {
                    Cars = TransactionManager.GetResourceMananger("car");
                }
            }
            if (Flights != null)
            {
                Console.WriteLine("Got RM with the name:" + Flights.GetName());
            }
            if (Rooms != null)
            {
                Console.WriteLine("Got RM with the name:" + Rooms.GetName());
            }
            if (Cars != null)
            {
                Console.WriteLine("Got RM with the name:" + Cars.GetName());
            }

            HttpChannel httpChannel = new HttpChannel(Int32.Parse(parser["p"]));

            System.Runtime.Remoting.Channels.ChannelServices.RegisterChannel(httpChannel, false);
            System.Runtime.Remoting.RemotingConfiguration.RegisterWellKnownServiceType
                (Type.GetType("MyWC.MyWC")                              // Assembly name
                , "WC.soap"                                             // URI
                , System.Runtime.Remoting.WellKnownObjectMode.Singleton // Instancing mode
                );

            Console.WriteLine("Staring Workflow Controller on port {0}", parser["p"]);


            while (true)
            {
                System.Threading.Thread.Sleep(100000);
            }
        }
Ejemplo n.º 8
0
        /// <summary>
        /*  WC runs as a separate process looping forever,
            waiting for the calls from other processes */
        /// </summary>
        static void Main(string[] args)
        {
            WCParser parser = new WCParser();
            if (!parser.Parse(args))
            {
                return;
            }

            //string rmFlightsURL = parser["f"];
            //string rmRoomsURL = parser["r"];
            //string rmCarsURL = parser["c"];
            string tmPort = parser["tmp"];
            string tmServer = parser["tms"];
            tmURL = tmServer + ":" + tmPort + "/TM.soap";

            while (TransactionManager == null)
            {
                try
                {
                    TransactionManager = (TP.TM)Activator.GetObject(typeof(TP.TM), tmServer + ":" + tmPort + "/TM.soap");
                    Transaction tid = TransactionManager.Start();
                    TransactionManager.Abort(tid);
                }
                catch (RemotingException e)
                {
                    TransactionManager = null;
                    Console.WriteLine("Waiting 1 second for Transaction Manager \"{0}\"", tmURL);
                    System.Threading.Thread.Sleep(1000);
                }
            }

            Console.WriteLine("Transaction Manager retrieved at {0}:{1}", tmURL, tmPort);
            while (Flights == null || Rooms == null || Cars == null)
            {
                if (Flights == null)
                    Flights = TransactionManager.GetResourceMananger("flight");
                if (Rooms == null)
                    Rooms = TransactionManager.GetResourceMananger("room");
                if (Cars == null)
                    Cars = TransactionManager.GetResourceMananger("car");
            }
            if (Flights != null)
                Console.WriteLine("Get RM with the name:" + Flights.GetName());
            if (Rooms != null)
                Console.WriteLine("Get RM with the name:" + Rooms.GetName());
            if (Cars != null)
                Console.WriteLine("Get RM with the name:" + Cars.GetName());

            HttpChannel httpChannel = new HttpChannel(Int32.Parse(parser["p"]));
            System.Runtime.Remoting.Channels.ChannelServices.RegisterChannel(httpChannel, false);
            RemotingConfiguration.RegisterWellKnownServiceType
                (Type.GetType("MyWC.MyWC")							    // Assembly name
                , "WC.soap"												// URI
                , System.Runtime.Remoting.WellKnownObjectMode.Singleton	// Instancing mode
            );

            Console.WriteLine("Starting Workflow Controller on port {0}", parser["p"]);

            while (true)
            {
                System.Threading.Thread.Sleep(1000);
                try
                {
                    TransactionManager.Ping();
                }
                catch(WebException)
                {
                    TransactionManager = null;
                    ReconnectToTM();
                }
            }
        }
Ejemplo n.º 9
0
        public Transaction Start()
        {
            try
            {
                return TransactionManager.Start();
            }
            catch (WebException)
            {
                TransactionManager = null;
                ReconnectToTM();
            }

            return null;
        }
Ejemplo n.º 10
0
        protected void StartUp(string url, string tmUrl)
        {
            if (string.Compare(tmUrl, "none", true) == 0)
            {
                return;
            }

            // Register with the TM
            while (transactionManager == null)
            {
                try
                {
                    this.transactionManager = (TP.TM)System.Activator.GetObject(typeof(TP.TM), tmUrl);

                    Transaction tid = this.transactionManager.Start();
                    this.transactionManager.Register(this.tmRegistrationString);
                    this.transactionManager.Abort(tid);
                }
                catch (Exception e)
                {
                    this.transactionManager = null;
                    Console.WriteLine(e.ToString());
                    Console.WriteLine("Waiting 1 second for Transaction Manager \"{0}\"", tmUrl);
                    System.Threading.Thread.Sleep(1000);
                }
            }
            Console.WriteLine("{0} RM: Transaction Manager retrieved at {1}", this.GetName(), tmUrl);

            // deal with prepared transactions
            this.ProcessPreparedTransactions();
        }