Background technology
At present, the application integration service between large enterprise's net is complicated day by day, and the system integration of traditional point-to-point formula seems awkward.In order to address this problem, people have proposed ESB (enterprise service bus, abbreviation ESB) notion, each subsystem of promptly forming enterprise network inserts a public information platform in the mode that is similar to connector, relatively independent each other, carry out unified data dispatch by scheduling engine, with high effective integration data and operation flow.Study the definition of being given with Gartner company of consulting firm according to famous IT, ESB is a kind of architecture, utilize Web service, message-oriented middleware, intelligent route and the switch technology of enterprise to realize, be the product that traditional intermediate technology combines with technology such as XML, Web services, ESB provides connection maincenter the most basic in the network.The target of ESB technology is to realize enterprise's application integration in standardized mode, finish interconnected, the intercommunication and the interoperability of business-to-business application system, standardization effort wherein comprises connector standardsization, management standardization, service message standardization and message criteriaization etc.
The appearance of ESB has changed traditional software architecture, can provide than the more cheap solution of traditional middleware software product, simultaneously it can also eliminate the technological disparity between the different application service, allows different application service coordinate operation, has realized communication and integration between the different services.On function, ESB provides the tupe of event-driven and document guiding, and distributed administrative mechanism, and it supports content-based route and filtration, has possessed the transmittability of complex data, and a series of standard interface is provided.For example, application number discloses a kind of implementation method of ESB for the Chinese patent application of " 200810227316.9 ".
Existing application is in the event-driven method of ESB, the service that provides as the ISP is in down state, comprise when service that the ISP provides was in presence not or service call person calls the service (being in non operating state) that the ISP provides outside the operating time, the event-driven method of existing ESB can not be called service, could call service when the service must waited until is in upstate, the person calls service at any time to be unfavorable for the service call; In addition, the event-driven method of existing ESB is carried out Synchronous Processing to service request, causes the disposal ability of ESB low.Wherein, so-called event-driven briefly is exactly that you order what button (what promptly produces), and what operation (promptly calling what function) computer carries out, and incident is not limited only to user's operation certainly.
And, existing E-commerce transaction platform, it is multi-to-multi that the service call person directly calls the ISP, chaotic, be difficult to maintenance management is carried out in the service in the row; The degree of coupling is too high between the realization of service call person and backstage service, often pull one hair and move the whole body, how many callers the backstage service has actually, application call which the service unclear cause difficult in maintenance, reliability between service call person and the ISP, transaction, synchronous/asynchronous communication, safety certification management all need to realize separately between the two, lack a public architecture; And, lack the unified approach of the backstage service being monitored, added up and provides the analysis data, be not easy to carrying out maintenance management towards the application of the architecture (Service-OrientedArchitecture, J is called for short SOA) of serving.
Summary of the invention
The problem that the present invention solves provides a kind of event-driven method that is applied to ESB, and the service call person needn't carry out complicated asynchronous call, is finished the conversion that is synchronized to asynchronous mode by service bus.
For addressing the above problem, the invention provides a kind of event-driven method that is applied to ESB, comprise: response is to the Event triggered of ESB, a plurality of service requests that the person sends to ESB that described incident comprises the service call, described response comprises that to the Event triggered of ESB handling described service request respectively sends call request to the service of correspondence;
Receive the result of the described call request that the service of described correspondence returns;
After the result of described a plurality of service requests is all returned, the result of described a plurality of service requests is sent to described service call person.
Optionally, described response also comprises the Event triggered of ESB:
Before handling described service request, judge whether the service that described service request is called is in upstate, if the service of being called is in down state, wait for that the service of being called becomes upstate.
Optionally, described service of calling is in upstate and comprises: the service of being called is in presence or operating state.
Optionally, described ESB comprises:
The message sink unit comprises a plurality of message sink passages, and each message sink passage is used to receive a plurality of service requests that described service call person sends to ESB;
Requesting processing is used to obtain described a plurality of service request, and respectively described a plurality of service requests is handled the back and send call request to the service of correspondence, receives the result of the described call request that the service of described correspondence returns respectively.
Optionally, described ESB also comprises:
The message queue unit is used for receiving the message that comprises described a plurality of service requests from described a plurality of message sink passages, and sorts by pre-defined rule;
The processing threads group is used for receiving from described message queue unit the ordering message of predetermined quantity, and sends to the described request processing unit.
Optionally, the described ordering by pre-defined rule is meant that the time sequencing that sends or receive by message sorts.
Optionally, described message comprises at least two service requests;
Optionally, described ESB also comprises: the request split cells sends to described message queue unit after being used for the message that described message sink unit receives split into service request.
Optionally, the described request processing unit comprises multiple request processing pipeline, and a kind of service request of pipeline alignment processing is handled in each request.
Optionally, described service comprises at least one application service, and described request processing unit processes service request comprises by predetermined flow process and generate at least one access request, and calls corresponding application service based on described access request and send call request.
Compared with prior art, the present invention has the following advantages:
The service call person is connected with electronic trade platform by the standard interface of ESB with the ISP, various application programs are integrated in electronic trade platform, by the event-driven method that is applied to ESB provided by the invention, ESB is realized calling between each application program, the service call person needn't carry out complicated asynchronous call, is synchronized to the conversion of asynchronous mode by ESB.
In addition, the event-driven method that is applied to ESB of the present invention, a kind of method of handling the incident of unusual service request is provided, judge at first whether the service that service request is called is in upstate, if the service of being called is in down state, wait for that the service of being called becomes upstate; After the service of being called becomes upstate, continue to handle service request.By a kind of like this event-driven method, the service call person can at any time carry out service call, and the person that needn't wait for the service call just can call when being in upstate, ESB at any time can respond services call, and judge by ESB whether the service called is upstate, service request is handled again when the service of being called becomes upstate.
Embodiment
The event-driven method that is applied to ESB of the specific embodiment of the invention, the service call person is connected with electronic trade platform by the standard interface in ESB with the ISP, various application programs are integrated in electronic trade platform, by the event-driven method that is applied to ESB provided by the invention, ESB is realized calling between each application program, the service call person needn't carry out complicated asynchronous call, is synchronized to the conversion of asynchronous mode by ESB.
In addition, the event-driven method that is applied to ESB of the present invention, a kind of method of handling the incident of unusual service request is provided, judge at first whether the service that service request is called is in upstate, if the service of being called is in down state, wait for that the service of being called becomes upstate; After the service of being called becomes upstate, continue to carry out service request.By a kind of like this event-driven method, the service call person can at any time carry out service call, and the person that needn't wait for the service call just can call when being in upstate, ESB at any time can respond services call, and judge by ESB whether the service called is upstate, service request is handled again when the service of being called becomes upstate.
With reference to figure 1, the event-driven method that is applied to ESB of the specific embodiment of the invention, comprise: step S1, response is to the Event triggered of ESB, a plurality of service requests that the person sends to ESB that described incident comprises the service call, described response comprises that to the Event triggered of ESB handling described service request respectively sends call request to the service of correspondence; Step S2 receives the result of the described call request that the service of described correspondence returns, and wherein, the result of the call request of a plurality of service request correspondences is returned respectively; Step S3 after the result of described a plurality of service requests is all returned, sends to described service call person with the result of described a plurality of service requests.Event-driven method of the present invention, essence be by service orchestration engine executing state machine (State Machine) model, provide convenience for the service call person, after the service call person sends a plurality of service requests, need not to wait for that all subsequent service request are just finished returns, service bus is notified the service call person after all service requests are all finished.
The event-driven method that is applied to ESB of the specific embodiment of the invention, described response also comprises the Event triggered of ESB: before handling described service request, judge whether the service that described service request is called is in upstate, if the service of being called is in down state, wait for that the service of being called becomes upstate.After the service of being called becomes upstate, handle described service request.Wherein, judge whether the service that described service request is called is in upstate, can judge the service that arbitrary service request that the service call person sends is called, also can judge some service that the service request that the service call person sends is called, this some service can the service of anomaly may occur for predetermined service.Described service of calling is in upstate and comprises: the service of being called is in presence or operating state.Event-driven method of the present invention to not being the 24x7 service or the not online situation of contingent service in (7 days one day 24 a hours week), shields, and conveniently calls the client of service and simply finishes the work.For example carry out in the buying and selling fund operation in bank, the user carries out fund and opens an account, and then business rule need consider whether crossed point in afternoons 3 now, if crossed point in afternoons 3, the fund service of opening an account is unavailable, need to wait for second day and could handle the request of opening an account after 9.This mechanism can be simplified service logic, the user can submit request at any time to, system judges service whether available (Available) automatically, for the service call under the down state, its continuation of Event triggered that the service state (Service Status) that needs wait to serve becomes after available (Available) is carried out.
Below in conjunction with ESB, describe the event-driven method that is applied to ESB of the present invention in detail.
With reference to figure 2, ESB 100, comprise: message sink unit 110, a plurality of service requests that the person that is used to receive the service call sends, each service request is used as an incident, comprise a plurality of message sink passages, be respectively message sink passage 1, message sink passage 2 ... message sink passage n, each message sink passage receives the message that comprises a plurality of service requests that a service call person sends;
Requesting processing 140, be used to obtain described a plurality of service request, with each service request as an incident, respectively described a plurality of service requests (a plurality of incident) are handled back corresponding service in calling service unit 150 and send call request, receive the result of the described call request that the service of described correspondence returns respectively; Wherein, requesting processing 140 is handled back corresponding service in calling service unit 150 with service request and is sent call request, is produced the result of service request by service corresponding in the service unit 150.Event-driven method of the present invention, with each service request as an incident, whenever handle a service request (incident), just the result of each service request is returned, rather than after the finishing dealing with of all service requests, again the result of all service requests is returned together, reach synchronization request to multiple application service, asynchronous process is also returned, conveniently different application services is called, and by event-driven method of the present invention, ESB can be unified to realize a plurality of service requests are carried out synchronization request, asynchronous process.
In this specific embodiment, requesting processing 140 comprises multiple request processing pipeline, and each request is handled pipeline and comprised a plurality of requests processing pipelines, a kind of service request of each request processing pipeline alignment processing; With reference to figure 3, requesting processing 140 comprises multiple request processing pipeline, be respectively first kind of request and handle pipeline 10, second kind of request processing pipeline 20 ... pipeline n0 is handled in the request of N kind, each request is handled pipeline and is comprised a plurality of requests processing pipelines, the service request that pipeline can be handled a plurality of same types is handled in every kind of request, handling pipeline 10 with first kind of request is example, and this first kind request handled pipeline 10 and comprised that pipeline 11 is handled in the request of being respectively of a plurality of requests processing pipeline, pipeline 12 is handled in request ... pipeline 1n is handled in request; Need to prove, there is corresponding relation in the kind that described request is handled pipeline with the kind request of service, pipeline is handled in the request of the corresponding identical type of each service request, the service request that comprises in each message will enter the request of corresponding kind and handle in the pipeline, handles the line treatment service request by request.
Wherein, in this specific embodiment, each request is handled pipeline and is comprised the deciphering stage (stage), the processing stage (stage), when this, corresponding message sink passage received message in deciphering stage, call ciphering unit to message encryption, the message of encrypting is deciphered by calling decrypting device, in other embodiments, pipeline is handled in each request can comprise the different stages, for example also can comprise decompression phase.See also Fig. 3, in this specific embodiment of the present invention, comprise service 151 in the service unit 150, described service 151 comprises at least one application service, in this specific embodiment, be application service 1, application service 1 ... application service n, handling service request processing stage of described comprises: generate at least one access request by predetermined flow process, and the application service of calling correspondence in the service unit 150 based on described access request, for example, request is handled the access request that generates in the pipeline 10 and is called application service 1, request is handled the access request that generates in the pipeline 20 and is called application service 2 ... request is handled the access request that generates among the pipeline n0 and is called application service n, wherein, access request is handled the back and is sent call request to the application service of correspondence, is produced the result of access request by the application service of correspondence.Wherein, application service is provided by the ISP, calls application service by access request.
In this specific embodiment of the present invention, be applied to the event-driven method of ESB, before access request is called corresponding application service, also comprise: judge respectively to before described a plurality of service requests (a plurality of incident) processing, also comprise: judge whether the service that described service request is called is in upstate, if the service of being called is in down state, wait for that the service of being called becomes upstate; After the service of being called becomes upstate, call corresponding service.For example, when the application service that credit is provided goes wrong to down state, before access request is called the application service of credit, whether the application service of at first judging credit is available, if unavailable, then access request is in wait state, and just judges at set intervals whether the application service of a credit is available, after the application service of credit became upstate, access request was just called the application service of credit.Wherein, the down state of the service among the present invention comprises: the service of being called is in presence not or on Monday calls service to eight working hours of Friday.By a kind of like this event-driven method, the service call person can at any time carry out service call, and the person that needn't wait for the service call just can call when being in upstate, judge by ESB whether the service of being called is upstate, service request is handled when the service of being called becomes upstate, the person sends service request at any time thereby can make things convenient for the service call again.
In another specific embodiment of the present invention, whether the application service that judgement is called is in upstate can also be before sending call request, before sending call request, the application service to correspondence also comprises: judge whether the application service that described access request is called is in upstate, if the application service of being called is in down state, wait for that the application service of being called becomes upstate.
Wherein, judge whether the service that described service request is called is in upstate, can judge the service that all service requests that the service call person sends are called, also can judge some service that the service request that the service call person sends is called, this some service can be predetermined service, for example, these predetermined services are not for being 24 * 7 service, promptly a week all is in the service of upstate seven day 24 hours every day, but 5 * 8 services (the week, the service that eight working hours times of every day can be used).
For the person that reduces the service call operates respectively different service requests, in a message sink passage, comprise at least one service request, the service call person can once propose a plurality of service requests; When the service call person once proposes a plurality of service request, the back form with message of a plurality of service requests packings that the user carries out is sent by the request packaged unit.In specific embodiments of the invention, the message sink passage is also by calling ciphering unit, with the message encryption of message sink passage reception.
See also Fig. 2, in this specific embodiment of the present invention, described ESB also comprises: message queue unit 120 is used for receiving message from message sink unit 110, and will come from a plurality of message of a plurality of message sink passages, rank according to time sequencing; Processing threads group 130 comprises the processing threads of predetermined quantity, is used for from described message queue unit 120 and receives the ordering message of predetermined quantities, and send to described request processing unit 140.
In specific embodiments of the invention, rank to the message that receives according to time sequencing in message queue unit 120, time the preceding message than the time after the message priority treatment, this time sequencing corresponding to the service call person file a request the operation sequencing, it also can be the sequencing that message queue unit 120 receives message, with reference to figure 1 and Fig. 2, the message queue after the queuing is respectively message queue 10, message queue 20 ... message queue n0; And before message enters message queue unit 120, message queue unit 120 call request split cells (not shown), by the request split cells message of packing is split into service request, the service request quantity that the quantity of this service request proposes corresponding to the service call person, with reference to the accompanying drawings 1, message in the message queue 10 is split into service request 11, service request 12, service request 13, message in the message queue 20 is split into service request 21, service request 22, service request 23, message among the message queue n0 is split into service request n1, service request n2, service request n3, need to prove, each message is split into three service requests in this example, be exemplary, in specific embodiment, the service request quantity that comprises in each message is (being service end user's operation) and decide as the case may be; Need to prove, in this specific embodiment of the present invention, the message in the message queue unit 120 is ranked according to time sequencing, also can rank to the message in the message queue unit in other embodiments of the invention, for example the message in the message queue unit be ranked according to the priority (importance) of message according to other pre-defined rules.
In another embodiment of the present invention, the message of packing is split also can be before the message sink passage receives message, and described message comprises at least two service requests; Described ESB also comprises: the request split cells sends to described message queue receiving element after being used for the described message that comprises at least one service request split into service request.In other embodiments of the invention, the message of packing is split also can be before processing threads group of received message, and described message comprises at least two service requests; Described ESB also comprises: the request split cells is used for receiving from described message queue unit message, and sends to described processing threads group after the message that comprises at least one service request that described message queue unit receives split into service request.
Processing threads group 130 comprises the processing threads of predetermined quantity being respectively processing threads 1, processing threads 2 ... processing threads n is used for from described message queue unit the 120 ordering message that receive predetermined quantities; The quantity of the processing threads in the processing threads group 130 is predetermined quantity, this quantity is set according to the disposal ability of electronic trade platform, for example, the quantity of the processing threads in the processing threads group 130 is 200, then same time electronic trade platform can only respond 200 message, and for the 200th later message, electronic trade platform does not respond, the person too much causes electronic trade platform to work as the phenomenon of machine to avoid the service call, thereby can guarantee the normal operation of electronic trade platform.Wherein, service request 11, service request 12, service request 13 that processing threads 1 stores in the message queue 10, service request 21, service request 22, service request 23 that processing threads 2 stores in the message queue 20 ... processing threads n stores service request n1, service request n2, the service request n3 among the message queue n0.
In specific embodiments of the invention, ESB also comprises: request transmits passage, is used for addressing, will send to corresponding application service from the access request that the described request processing unit generates.
In this specific embodiment of the present invention, the service request of being handled by requesting processing 140 returns to service call person's process is opposite with the processing procedure that the service caller sends service request, at first transmitting passage by request will call information after the application service and send to corresponding request and handle pipeline, after asking the processing pipeline, send to corresponding processing threads with information encryption, request processing thread sends to corresponding message queue with the result of the service request that receives, send to corresponding message sink passage afterwards, when all service request results that comprise in the message return its corresponding message sink passage, message sink passage call request packaged unit, send to corresponding service call person after all message packings that will comprise in the message, this moment, the user can obtain the result of the message that sent.Need to prove, event-driven method of the present invention, with each service request as an incident, whenever handle a service request (incident), just the result of each service request is returned, rather than after the finishing dealing with of all service requests, again the result of all service requests is returned together, reach synchronization request to multiple application service, asynchronous process is also returned, conveniently different application services is called, and by event-driven method of the present invention, ESB can be unified to realize a plurality of service requests are carried out synchronization request, asynchronous process.
Though the present invention with preferred embodiment openly as above; but it is not to be used for limiting the present invention; any those skilled in the art without departing from the spirit and scope of the present invention; can utilize the method and the technology contents of above-mentioned announcement that technical solution of the present invention is made possible change and modification; therefore; every content that does not break away from technical solution of the present invention; to any simple modification, equivalent variations and modification that above embodiment did, all belong to the protection range of technical solution of the present invention according to technical spirit of the present invention.