/// <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(); } } }