The dynamic routing method of the service call of multistage service bus under the SOA framework
Technical field
The present invention relates to information sharing and cooperation between the service under a kind of SOA framework, the dynamic routing method of the service call of distributed multi-stage service bus under specifically a kind of SOA framework.
Background technology
Service is the unit of processing and management data, is distributed in each system of enterprise.It is by message and other system or other communication for service.The exchange of message is undertaken by the data exchange agreement of standard.Each service all has a unique service code to identify this service, and each service all has a unique service address, and normally a URL indicates the position of serving the place.
Service catalogue is used for the unified management of information on services, comprises registration, modification, deletion of information on services or the like, and all information on services all must be registered in service catalogue.The information that the service of having stored in the service catalogue is relevant comprises code, description, parameter, QoS information, address of service of service or the like.
Service bus provides calling of serving, and the caller of all services must call service by service bus, and the caller of avoiding serving directly calls service, realizes the loose coupling between caller and the service.Each service bus all has a unique bus code.
Dynamic routing is meant the service call, and the person does not need the address of the service of knowing, he provides service code when calling service bus, and service bus dynamically obtains the process of address of service according to service code inquiry service catalogue.The close coupling of service call person and service has been avoided in dynamic routing.
SOA is that Enterprise SOA can make the application and development pipelining, and the core architecture problem of SOA is control, quality and management.
Under the SOA framework, service distribution is in each system of enterprise, and the unified management that service catalogue is used to serve is only disposed a service catalogue in the general enterprise, and that service bus can be disposed is a plurality of.
Service bus can multistagely be disposed, and such as a service bus of system deployment at province center, the system of each districts and cities of province's center administration also disposes a service bus, and the secondary districts and cities system of each districts and cities' administration also disposes a service bus; Service bus also can be disposed according to application system, disposes a service bus such as financial system, and marketing system is disposed a service bus; Service bus also can be disposed according to performance requirement, and such as being that a service bus is disposed in the high service of performance requirement separately, the another one service bus is used in other service.Like this, in whole enterprise, all service bus have formed distributed, a multistage framework.
Service can be bundled on certain specific service bus, if a service binding on certain service bus, this just means to have only this specific service bus could visit this service, other service bus all can not be visited this service.Can be bundled on the specific service bus such as the service that relates to the high service of level of securitys such as the amount of money, secret, sensitive data or do not want to allow external system directly visit, make the caller of service must call the service specified bus, prevent potential safety hazard.
The connectivity setting is arranged between a plurality of service bus, so-called connectivity setting is meant that if two service bus are UNICOMs, they can call the upward service of the other side that is bundled in so, if two service bus are not UNICOMs, they can't call the service that is bundled on the other side so.The connectivity configuration information is kept on the service bus.
The connectivity of service bus makes and has formed a netted syndeton between a plurality of buses.
One of target of SOA is to realize the dynamic routing of service, loose coupling between feasible service and the service caller, for the SOA framework that has only single service bus, the problem that does not have service bus connectivity and service binding, be easy to realize to serve and serve the loose coupling between the caller, but for the SOA framework of distributed multi-stage bus, there is following problem in dynamic routing:
1. the service call person must know whether service has bound specific service bus, if service binding on specific bus, caller must call this specific bus just can have access to this service.If caller can't directly be visited this specific bus, then can produce following the 3rd described situation.
2. if service was bundled on the service bus A originally, changed into afterwards and being bundled on the service bus B, Fu Wu caller also will call service bus B from calling service bus A instead so, the close coupling of so just cause service call person and service.
The service call person directly access services bind service bus the time, in different VPN or the service call person service bus that do not have the direct access services of authority to be bound, just need know a plurality of service bus link relations such as service call person and service center.The person that supposes the service call is because the restriction of network condition, can only access services bus A, and the service bus N that then wants the service of calling and service to bind is among another VPN, can not directly visit.Because the connectivity of service bus makes and has formed a netted syndeton between a plurality of buses, the service call person must calculate the shortest path that is connected to the route of service bus N from service bus A, could allow service bus A according to shortest path pass-along message, call the service that is bundled on the service bus N.In case the service bus connectivity is changed, the service call person just need recomputate shortest path, cause service call person and service bus connectivity close coupling.
4. the connectivity information of service bus leaves on the service bus, makes to come into plain view enterprise's neither one figure of bus UNICOM intuitively, and management is inconvenient.
Summary of the invention
The close coupling of service that causes in order to overcome above-mentioned problem and service caller, make SOA lose due meaning, the purpose of this invention is to provide a kind of new under the SOA framework dynamic routing method of the service call of distributed multi-stage service bus, this method is come the connectivity information of service bus with service catalogue rather than service bus, service catalogue provides the shortest path of route to calculate, when the service call person calls service bus, only need provide service code, the shortest path that service bus inquiry service catalogue obtains route carries out route according to shortest path again.This method can make the service call person and the real loose coupling of service.
The objective of the invention is to be achieved through the following technical solutions:
The dynamic routing method of the service call of distributed multi-stage service bus under a kind of SOA framework is characterized in that it may further comprise the steps:
(1) the service call person calls the service specified bus, and the input service code;
(2) after the service specified bus interface is received service request, import two parameters: bus code and service code 7, call the shortest path computing function of service catalogue;
(3) service catalogue inquires the position of the service bus that this service code binds according to service code, then according to the connectivity information of bus, calculate the shortest path of service specified bus, and shortest path is returned to the service specified bus to the service bus of binding;
(4) after the service specified bus interface is received shortest path, finding has shortest path in the request msg, then judge oneself to be last bus of this shortest path, if, then the service code that called of explanation is bundled on the service bus at own place, and this service bus is the service code place at service call person's the request msg person place that sends to the service call; If not, judge the next bus code in the shortest path again, the service specified bus adds shortest path in service call person's request msg, the request msg of shortest path and service caller is sent to next service bus in the shortest path together, get back to step (4), carry out cycling.
Among the present invention:
1. service catalogue also needs the information of service bus except service information, and the information of service bus comprises the address of service bus, service bus code, connectivity information of service bus or the like.Also need the binding information of service and service bus in the service catalogue.Service catalogue provides the management function to service bus information, service and service bus binding information.
2. the function according to the shortest path of bus code and service code calculating route is provided on the service catalogue.
3. when the service call person calls service bus, only need provide service code, service bus inquiry service catalogue obtains the shortest path of route.
4. service bus carries out route according to shortest path.
The present invention is under the SOA framework, when disposing the distributed multi-stage service bus, close coupling for fear of service call person and service, use service catalogue rather than service bus to come the connectivity information of service bus, service catalogue provides the shortest path computing function of route, when the service call person calls service bus, only need provide service code, service bus calls the shortest path computing function of service catalogue according to the code of service code and this bus, obtain the shortest path of route, carry out route according to shortest path again.
The present invention has realized the loose coupling of service call person and service; And with the information of service catalogue service bus and the information of service binding service bus, very little to the adjustment of whole SOA framework, therefore have favorable compatibility; Adopt method of the present invention, the person's that can reduce the service call exploitation amount does not need any change is done in service; The information of service catalogue service bus and the information of service binding service bus can provide the netted view of the unified service bus UNICOM of overall situation for enterprise, come into plain view, and are convenient to management.
Description of drawings
Fig. 1 is the schematic diagram of bus connectivity and service binding bus among the present invention.
Fig. 2 is the schematic flow sheet of the method for the invention.
Embodiment
Below in conjunction with drawings and embodiments the present invention is elaborated.
Fig. 1 is the schematic diagram of bus connectivity and service binding bus among the present invention.Wherein, service bus A, B, the mutual UNICOM of C, bus C and bus D, E UNICOM.If have caller want by service bus B call the service 7, then the shortest path of route be bus B->bus C->bus E->service 7.
Specific implementation method of the present invention is as follows:
In Fig. 2, suppose bus connectivity and service binding bus as shown in Figure 1, there is a service call person to want by the service bus B service of calling 7, process is as follows
1. the service call person calls service bus B, input service code: 7.
2. after service bus B receives service request, call the shortest path computing function of service catalogue, import two parameters: bus code B and service code 7.
3. because the connectivity information of bus and the information of service binding bus all are kept on the service catalogue now, service catalogue can be bundled on the service bus E according to service code 7 service of inquiring 7, then according to the connectivity information of bus, calculate service bus B to the shortest path of service bus E be bus B->bus C->bus E, it returns to service bus B to shortest path B.C.E.B in the shortest path, C, E are the bus codes of bus B, bus C, bus E, use. separate.
4. after service bus B receives shortest path B.C.E, judge it oneself is not last bus of this shortest path, judge that the more next bus in the shortest path is bus C, service bus B adds shortest path B.C.E in service call person's request msg, the service bus C that sends together of request msg of shortest path and service caller.
5. after service bus C receives request, finding has shortest path B.C.E in the request msg, it is judged oneself is not last bus of this shortest path, judge that the more next bus in the shortest path is bus E, the service bus E that service bus E sends the request msg of shortest path and service caller together.
6. after service bus E receives request, finding has shortest path B.C.E in the request msg, it is judged oneself is last bus of this shortest path, illustrates that it oneself is on the service bus E that the service 7 of being called is bundled in, and service bus E is service call person's the request msg service of sending to 7.
This shows that in this process, the service call person only need know service code, whether be bundled on the specific service bus, also do not need to know the connectivity of service bus and need not the service of being concerned about.Adopt this method, make under the SOA framework, the loose coupling of service call person and service has really been accomplished in the dynamic routing of distributed multi-stage bus service call.
Because present most SOA framework all is that the connectivity information of service bus is kept on the service bus, calculate the shortest path of route by service call person oneself, thereby the close coupling of cause service call person and service, the present invention is by being calculated the shortest path of route by service catalogue, make the service call person only need know service code, whether be bundled on the specific service bus and need not the service of being concerned about, do not need to know the connectivity of service bus yet, really accomplished the loose coupling of service call person and service, go for the SOA framework that all dispose the distributed multi-stage service bus, have very high realistic meaning.
With the information of service catalogue service bus and the information of service binding service bus, very little to the adjustment of whole SOA framework, therefore have favorable compatibility.
Adopt the present invention, the person's that can reduce the service call exploitation amount does not need any change is done in service.
The information of service catalogue service bus and the information of service binding service bus can provide the netted view of the unified service bus UNICOM of overall situation for enterprise, come into plain view, and are convenient to management.