Construction of service station
The terminus acts as the transaction processing and coordination in the system. Each client must connect to the terminus before requests are required. Process the service provided by the terminus. In the specific coding implementation, the station's position is the same as that of several other servers. When calling it, you only need to find the method of the corresponding station for processing. The main functions are as follows:
Namespace globalservice {// <summary> // all transactions must be executed using the following processtransaction () method: /// * 1. accept and set the table transaction number string Xid // 2. implement icarremoteservice m_carremoteservice by accepting and setting the service interface of table car; // 3. ihotelremoteservice m_hotelremoteservice is implemented by accepting and setting the service interface of the table hotel; // 4. implement iflightremoteservice m_flightremoteservice by accepting and setting the flight service interface; // 5. implement icustomerremoteservice m_customerremoteservice by accepting and setting the service interface of table customer; // 6. implement ireservationremoteservice m_reservationremoteservice by accepting and setting the service interface of table reservation; // * 7. the transactionentity m_transactionentity service interface of the transactionentity table is accepted and set; // </Summary> public class globalcontrolserviceimpl: externalbyrefobject, iglobalcontrolservice {
Parameter List of the terminus
Static void main (string [] ARGs) {# Start the region terminus // tcpserverchannel changlobalservice = new tcpserverchannel (9991); // channelservices. registerchannel (changlobalservice, false); // remotingconfiguration. registerwellknownservicetype (typeof (globalcontrolserviceimpl), "service", wellknownobjectmode. singleton); binaryserverformattersinkprovider serverprovider = new binaryserverformattersinkprovider (); binaryclientformattersinkprovider clientprovider = new binaryclientformattersinkprovider (); serverprovider. typefilterlevel = typefilterlevel. full; idictionary props = new hashtable (); props ["name"] = "remotetcp"; props ["Port"] = "9991"; tcpchannel Chan = new tcpchannel (props, clientprovider, serverprovider); channelservices. registerchannel (Chan, false); remotingconfiguration. registerwellknownservicetype (typeof (globalcontrolserviceimpl), "service", wellknownobjectmode. singleton); remotingconfiguration. registerwellknownservicetype (typeof (queuetransactionserviceimpl), "queue", wellknownobjectmode. singleton); console. writeline ("terminal started successfully... "); console. readline (); # endregion # connect the region terminus to the car table // tcpclientchannel Chan = new tcpclientchannel (); // channelservices. registerchannel (Chan, false); // icarremoteservice carremoteservice = (icarremoteservice) activator. getObject (typeof (icarremoteservice), "TCP: // localhost: 9999/search", null); # endregion}
Terminal startup code
Because the terminus needs to operate on each data service set, it must also accept the interface implementation class of each data service set when accepting parameters to ensure normal operation of the data set.
Figure. Relationship between servers, servers, and clients