Summary of the invention
The objective of the invention is in the prior art, the traditional method that allows systems soft ware that active responding is made in environmental change promptly uses the existing problem that needs precognition various running environment, higher code complexity and superior performance expense of adaptability code, a kind of system and method thereof of message handling system being carried out the heat renewal proposed, the edition upgrading function of non-interrupting service is provided, thereby promote the extensibility of software systems, cut operating costs.
Technical scheme of the present invention is:
A kind of system that message handling system is carried out the heat renewal, between network communication module and business logic processing module, increase a heat and upgrade control module, network news module communicates as information receiving and transmitting end and other network element device of message handling system, the network communication module is upgraded control module with heat and is connected, heat is upgraded control module and is connected with the business logic processing module, described heat is upgraded control module and is comprised: initialization component, the business process control assembly, transmit control assembly, process status table and control command processing components, initialization component are responsible for hot update module and the startup of business logic processing module and relevant preparation; The business process control assembly communicates by inside story with transmitting control assembly, finishes the control of business process and the forwarding work of message; Process status table is a sharing data area, and business process control assembly and forwarding control assembly all can be visited the data in this blocks of data district; Control command processing module user accepts and corresponding manual or automatic control command.
A kind of based on the described system of claim 1 message handling system is carried out hot method for updating, it may further comprise the steps:
(a). redaction business function treatment progress to be updated is deployed under the main frame catalogue of appointment, renewal control interface by the control command processing components, send version updating message and give the business process control assembly, after the business process control assembly is received version updating message, according to the version number information that carry message the inside, determine target version this shop and the target version this shop of redaction is write the target version this shop field of process status table;
(b). get a record in the process status table, with the business process identification record of early version in local variable, according to target version information in the process status table, whether seek corresponding executable file under assigned catalogue exists, if there is no, then point out error message, stop upgrading operation, the update instruction failure; If exist then continuation;
(c). start this executable file corresponding service function treatment process of redaction, the record in the process status table remains the record of early version process at this moment, transmits control assembly and still normally moves with reference to the record in the process status table;
(d). receive the registration message of redaction business function treatment progress when the business process control assembly after, immediately by the record in the atomic operation renewal process status table, it is the information of redaction process that business process in record processing sign is waited content update, according to the Business Processing process identification (PID) of noting the early version in local variable among the step b, the transmission process withdraws from message to early version business function treatment progress; After the business request information of early version business function treatment progress in handling message queue, begin to handle and withdraw from message, that is correlated with withdraws from preparation, discharge corresponding internal memory after, the early version business process withdraws from;
(e). repeat b to the d step, the record traversal processing in whole process status table is finished, and gives the current version field with the numerical value assignment of the target version field in the process status table, upgrades operation and finishes.
Beneficial effect of the present invention:
The invention provides the edition upgrading ability of non-interrupting service, effectively reduce operation maintenance cost; The framework process is separated with business process, the program degree of coupling is low, and boundary is clear and definite clear; Scheme is mature and stable, good reliability.
Embodiment
Below in conjunction with drawings and Examples this method is further described.
The feature of hot renewal technology of the present invention is:
The framework process is separated with business process, carries out interprocess communication by message queue, shared drive; System framework gives information, and formation is created, management, forwards, scheduling feature; Business function is handled the tupe that adopts multi-course concurrency; The Business Processing process can the receiving system framework control messages finish corresponding action; System framework can start, identification services process version; System framework provides the control messages interface, can receive and handle the edition upgrading instruction; The Business Processing process is distinguished version by the mode that filename adds version number's suffix; System framework is transmitted message by identification process version and the suitable process of state information acquisition in transmitting the Business Processing message process; By atomic operation, provide high efficiency concurrent access control.
During concrete enforcement:
One, as shown in Figure 1, the feature of hot update method provides the module of a forwards, and message transmitting module comprises following assembly:
The network communication assembly: maintenance, chain rupture detection, the chain rupture of being responsible for the TCP/IP link reconnect, as the external interface of whole message handling system;
System initialization assembly: each component processes of being responsible for creating shared drive, message queue, startup framework.And process initiation is provided, API such as stops and using to other assembly.
The shared drive message buffer: in order to improve the message of Message Processing, reduce the unnecessary memory data and duplicate, all message datas all leave in the shared drive.Send the address offset amount of message body in shared drive to target process by the operating system message queue when message is transmitted, target process goes to obtain in the shared drive message body data voluntarily.
The business process control assembly: version, the operating state of identification and storage service process start, stop business process.
The forwarding strategy assembly: the information according to Version Control assembly, process control assembly provide is transmitted to specific business function treatment progress according to strategy with service message.
Message schedule component: finish concrete shared drive buffer area access, message transmission, message scheduling feature, and provide API such as corresponding business process message formation load, timer message to use to other assembly.
The control command processing module: the main message of being responsible for receiving control desk provides system maintaining interface.
Two, key data structure
1, the process status table of framework maintenance:
Process status table has kept the operating state, version number, message queue of process to overstock process relevant informations such as situation, by process status Version Control assembly, regularly and by the mode of message trigger upgrades and safeguards that its data structure has the C language representation as follows:
The structure information storage PNOInfo of each Business Processing process
typedef?struct
{
Unsigned long long PNO:14; Process of unique identification in the // framework
Unsigned long long State:4; // process status
Unsigned long long QueueNum:14; The load of // message queue
Unsigned long long PID:32; The operating system process number that //OS distributes
}PNOInfo;
The storage organization SvrGroup of the business process of each type of service
typedef?struct
{
UINT16 ServiceType; // the type of service that receives
UINT8 CountPNO; // can handle the quantity of the business process of this type of service
PNOInfo theProc[MAXPNONUM]; //PNOInfo information array
}SvrGroup;
The storage organization ProcStateMap of whole process status table
typedef?struct
{
UINT32 CurrVersionID; // business process current version number
UINT32 DestVersionID; // business process target version this shop
SvrGroup DisSvrPNO[MAXSVRTYPE]; The state table of // each business process group
}ProcStateMapProcInfo;
2, both data structure of the marking mode of business procedure filename and version number
The business process control assembly of framework comes the version of differentiated service function treatment process by the version number information of filename name suffix.
The naming rule of business process version number:
<business procedure name〉<_<a.b.c.d 〉
Example: OCS_1.0.0.106
Wherein a, b, c, d represent four parts of the version number of business application respectively, each part period (.).First underscore (_) that runs into forward at last from whole filename is as the decollator of business procedure name and version number.
The span of a, b, c, d is 0~255 (8), forms 32 bit data according to order from high to low, is kept in 32 the data field, and corresponding data structure is as follows with the C language representation;
The storage organization ProgVersion of business process version
typedef?struct
{
UINT8 ProgMame[128]; // business process filename
UINT32 VersionID; // business process target version this shop
}ProgVersion;
Three, the control of the multi-course concurrency of high efficiency process status table visit
In the process status table, the process status information of preservation is to carry out reference data important in the forwards processing procedure, relates to a plurality of processes or concurrent visit, and under situation about guaranteeing data security, we have used atomic operation to guarantee treatment effeciency.
PNOInfo record is one 64 a data structure, and the unix platform of various main flows all provides the api interface of 64 bit data atomic operations, and the data structure characteristic of PNOInfo can realize by the access control of atomic operation process.
Four, the handling process during system start-up
As shown in Figure 2, system carries out following steps when starting:
1, start-up system initialization component process;
2, system initialization assembly, establishment shared drive buffering area, message queue are prepared corresponding table structure, start other process in the framework then;
3, after other framework process initiations finish, initialization component initialization for causing message is given all framework processes;
4, the business process control assembly is received initial message, beginning analysis configuration file;
5, the catalogue of the business process of appointment and process name in the scan profile obtain the version information that business process can be used according to the business process version number information of filename suffix;
6, the business process version number that obtains most complete, the maximum version of version is a current business process version number;
7, the business function treatment progress of the version number that determines of the API setting up procedure 6 that provides by initialization component of business process control assembly;
8, the business process control assembly starts timer, regularly the running status of Collection and analysis business process;
9, behind the business function process initiation, initialization component can initialization for causing message be given the business function treatment progress, and business function is handled and carried out initialization operation;
10, after the initialization of business function treatment progress was finished, the business process control assembly that registration message is given framework took place;
11, after the business process control assembly is received the registration message of business process, upgrade the data in the process status table, increase the record of a sign time business function treatment progress;
12, when the 4th one was carried out, the forwarding control assembly of framework was received initial message equally, carries out initialization action;
13, when a plurality of business function treatment progress were finished initialization and registration by above-mentioned 7~11 steps after, system start-up finished, and the Message Processing service of all-round power can externally be provided.
Five, system business Message Processing flow process
As shown in Figure 3, system carries out following steps in the message of managing business:
1, the frame network communication part receives the Business Processing request message that network transmits, and message body is deposited in the shared drive buffering area;
2, give the forwarding control assembly by the side-play amount address of message queue generation business request information in shared drive;
3, after the forwarding control assembly is received message, obtain this message, analyze the corresponding service type (ServiceKey) of this message at the shared drive buffering area;
4, transmit control assembly,, in process status table, obtain the record of the business function treatment progress that can handle this type of service message according to hash algorithm;
5, judge according to the process status field in the process status table whether this process is in normal condition;
6 if normal condition is then given corresponding service function treatment process with forwards, otherwise changes for the 9th step;
7, the business function treatment progress is subjected to handling accordingly behind the Business Processing request message, generates professional response message;
8, by the network service assembly, professional response message returns to distant place main frame;
If 9 corresponding service function treatment process statuss are unusual, will travel through process status table so, search other processes of the kind of message of can managing business;
If 10 find the business function treatment progress of available normal condition, then business request information is transmitted to the Business Processing process, change step 7 then over to;
If 11 can not find available business function treatment progress, then enter the overload handling process, the overload handling process does not belong to this civilian category;
12, in the process that as above 1~11 step is carried out repeatedly, the business process control assembly is by timer and two kinds of mechanism of message trigger, constantly collect whole service function treatment state of a process and judge the ruuning situation of Business Processing process, upgrade the content in the business process state table, use for transmitting control assembly.
Six, system's heat is upgraded flow chart
As shown in Figure 4, system is carrying out carrying out following steps when heat is upgraded:
1, the business function handling procedure by the installation procedure redaction copies under the main frame catalogue of appointment;
2, by control command processing components or renewal control interface, version updating message takes place give the business process control assembly;
3, after the business process control assembly is received version updating message, analyze, determine target version this shop according to the version number information of carrying in the message;
4, target version this shop is write the target version this shop field of process status table;
5, the traversal process status table repeats 6~12 steps, handles record wherein one by one;
6, get a record in the process status table, charge in the variable;
7, according to target version information, under assigned catalogue, seek corresponding executable file and whether exist, if there is no enter the abnormality processing flow process, then update instruction failure; If exist then continuation;
8, start the business function treatment progress of a redaction, the record in the process status table remains the record of early version process at this moment, transmits control assembly and still can normally move with reference to the record in the process status table;
9, after the business process control assembly is received the registration message of business process of redaction, upgrade record in the process status table by atomic operation immediately, be the information of redaction process with the content update in the record.When transmitting the process that control assembly will be transmitted to follow-up Business Processing request message redaction, the process of early version can not received any new business request information more like this;
10, business process control assembly, according to the progress information of noting the early version in variable in the step 6, the transmission process withdraws from message to early version Business Processing process, and this message must be last message in the message queue of the business function treatment progress of early version;
11, the Business Processing process of early version after the business request information in handling message queue, begins to handle last and withdraws from message, and that is correlated with withdraws from preparation, discharge corresponding internal memory after, the early version business process withdraws from.
12, forward the 6th step to, the record in whole process status table is all finished dealing with;
13, give the current version field with the numerical value assignment of the target version field in the process status table;
14, upgrading operation finishes.
If 15 find that the business function handling procedure of redaction has problem, can repeat above-mentioned steps, know the version number of early version, can return back to the business function handling procedure of version rapidly.
This method does not relate to the part prior art that maybe can adopt all same as the prior art and is realized.