CN110377437A - Communication means, computer equipment and storage medium between a kind of micro services - Google Patents
Communication means, computer equipment and storage medium between a kind of micro services Download PDFInfo
- Publication number
- CN110377437A CN110377437A CN201910655479.5A CN201910655479A CN110377437A CN 110377437 A CN110377437 A CN 110377437A CN 201910655479 A CN201910655479 A CN 201910655479A CN 110377437 A CN110377437 A CN 110377437A
- Authority
- CN
- China
- Prior art keywords
- micro services
- request
- services end
- micro
- sent
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/46—Multiprogramming arrangements
- G06F9/54—Interprogram communication
- G06F9/542—Event management; Broadcasting; Multicasting; Notifications
Abstract
The invention discloses communication means, computer equipment and storage medium between a kind of micro services, wherein method are as follows: the first micro services end is determined for handle the first the second micro services end requested;First micro services end determines the first micro services example that first request is handled in second micro services end according to the micro services list of acquisition;Second request is sent to second micro services end by first micro services end, includes information, the information of first request and the first micro services example at first micro services end in second request.The above method is applied at the field financial technology (Fintech), and the first micro services end may specify specific micro services example, increases the selectivity of micro services example, to improve the diversity that micro services end sends request.
Description
Technical field
The present invention relates in financial technology (Fintech) the micro services communications field more particularly to a kind of micro services between lead to
Letter method, computer equipment and storage medium.
Background technique
With the development of computer technology, more and more technologies (big data, distribution, block chain (Blockchain),
Artificial intelligence etc.) it applies in financial field, traditional financial industry gradually changes to financial technology (Fintech).Currently, financial
In sciemtifec and technical sphere, with the rise of micro services, for the interaction for realizing Financial Information, often there is phase between the micro services of financial business
The demand of mutual communication.
Micro services include multiple micro services examples, and transmission user request is specifically to be carried out by micro services example between micro services
's.At present in method, when a micro services are requested to another micro services transmission user, another micro services can only be randomly choosed
Micro services example.It for example, is random when user's request that the micro services example A of micro services one is sent to micro services two
It is sent to some micro services example B of micro services two.Therefore for these reasons, logical between micro services at present at present in method
Letter mode is more single, it is difficult to meet diversified business demand.
Summary of the invention
The embodiment of the present application provides communication means, computer equipment and storage medium between a kind of micro services, solves existing
Communication mode in technology between micro services is more single, it is difficult to the problem of meeting diversified business demand.
In a first aspect, the embodiment of the present application provides communication means between a kind of micro services: the first micro services end is determined for locating
Second micro services end of the first request of reason;First micro services end determines that described second is micro- according to the micro services list of acquisition
The first micro services example of first request is handled in server-side;Second request is sent to described by first micro services end
Second micro services end, it is described second request in include first micro services end information, it is described first request and described first
The information of micro services example.
In the above method, due to the first micro services end determined for handle first request the second micro services end, first
Micro services end is according to the micro services list of acquisition, it is determined that first that the first request is handled in the second micro services end is pragmatic in incognito
Example, thus before transmitting, it is determined that the micro services example that the second request will occur, and the first micro services end is directly by second
Request is sent to second micro services end, due to the information in the second request including the first micro services end, first request
With the information of the first micro services example, thus second service end can also know the first micro services example send request it is specific
Micro services example, the first micro services end may specify specific micro services example, increase the selectivity of micro services example, to mention
The diversity that micro services end sends request is risen.
In a kind of optional embodiment, the second request is sent to second micro services end by first micro services end,
It include: the response modes that first micro services end determines first request;First micro services end is according to described first
Second request is sent to second micro services end by the response modes of request.
In the above method, the first micro services end first determines the response modes of first request, sends out according still further to response modes
It send the second request to the second micro services end, increases the diversity of micro services end communication means so as to mode according to response.
In a kind of optional embodiment, the micro services list has indicated at least one of second micro services end
The micro services example of micro services and each micro services;First micro services end according to the micro services list of acquisition, determine described in
The first micro services example of first request is handled in second micro services end, comprising: first micro services end is if it is determined that institute
Stating the first request is broadcast type, then first request is corresponded to all micro services of micro services in the micro services list
Example is as the first micro services example for handling first request.
In the above method, it can be broadcast type by specified first request, realize and the first request is broadcast to second in incognito
The communication mode for all micro services examples being engaged in end.
In a kind of optional embodiment, first micro services end determines described second according to the micro services list of acquisition
Before the first micro services example for handling first request in micro services end, further includes: first micro services end determines institute
Stating the first request is the response contents for caching type and uncached first request.
Under aforesaid way, provides and determine that handle first request in second micro services end first is pragmatic in incognito
A kind of precondition of example, specific precondition are as follows: the first micro services end determines first request for caching type and uncached
The response contents of first request.
In a kind of optional embodiment, first micro services end is if it is determined that first request is caching type and has delayed
The response contents for depositing first request then return to the response contents of first request and abandon first request.
Under aforesaid way, the first micro services end is if it is determined that first request is asked to cache type and having cached described first
The response contents asked, no need to send the first requests, directly return to the response contents of the first request and abandon first request
, to further increase communication diversity, and which can save the communication resource.
In a kind of optional embodiment, first micro services end receives third request, and the third request is that third is micro-
What server-side was sent, information, the 4th request and described first in the third request including third micro services end are in incognito
The information for the second micro services example being engaged in end;Described in the second micro services instance processes in first micro services end
Four requests;If first micro services end can obtain the response contents of the 4th request, the sound of the 4th request is sent
Answer content to the third server-side.
Aforesaid way is the mode that the first micro services end receives third request, due to including third micro services in third request
Therefore the information of the information at end, the 4th request and the second micro services example in the first micro services end passes through third micro services end
The second specified micro services example handles the 4th request, and if the first micro services end energy in the first micro services end
The response contents for obtaining the 4th request then send the response contents of the 4th request to the third server-side, thus
Realize reception and processing that third is requested at the first micro services end.
In a kind of optional embodiment, the 4th described in the second micro services instance processes in first micro services end
Request, comprising: if the 4th request is Asynchronous Request, first micro services end is called described in the processing of the first preset function
4th request, and whether there is according to the response contents for calling the result of first preset function to determine that the described 4th requests;
If the 4th request is synchronization request, the second preset function processing the 4th request is called at first micro services end,
And using the return value of second preset function as the response contents of the 4th request;Second preset function is silent to have
Recognize the function of return value.
Aforesaid way can be Asynchronous Request or synchronization request according to the 4th request, call at different preset functions
Reason, to obtain different response results, to further increase the communication diversity between micro services end.
In a kind of optional embodiment, first micro services end by the second request be sent to second micro services end it
Before, further includes: first micro services end generates Feign client;The Feign client is for accessing described second in incognito
The request receiver at business end;The request receiver is the interface for accessing the first micro services example;First micro services
Second request is sent to second micro services end by end, comprising: first micro services end passes through the Feign client
Second request is sent to the request receiver, to be sent to described second in incognito by the request receiver by end
The the first micro services example being engaged in end.
Under aforesaid way, the first micro services end generates Feign client, by the Feign client, by described second
Request is sent to the request receiver, to be sent to described the in second micro services end by the request receiver
One micro services example, to realize the communication means between the micro services end based on Feign client.
In a kind of optional embodiment, first micro services end and second micro services end are deployed in Feign frame;
First micro services end and second micro services end include HTTP interface;First micro services end is sent out by the second request
Give second micro services end, comprising: first micro services end is sent to institute according to http protocol, by second request
State the second micro services end.
Under aforesaid way, the first micro services end and the second micro services end are deployed in Feign frame, are based on to realize
The micro services end sending method of Feign frame, moreover, because the first micro services end and the second micro services end connect including HTTP
Mouthful, the sending method based on http protocol may be implemented in the first micro services end, and the second request is sent to the second micro services end.
In a kind of optional embodiment, first micro services end determines described second according to the micro services list of acquisition
Before the first micro services example for handling first request in micro services end, further includes: if first micro services end determines
The third micro services example in second micro services end for handling first request, then first micro services end
5th request is sent to second micro services end, includes information, the institute at first micro services end in the 5th request
State the information of the first request and the third micro services example.
Under aforesaid way, the first micro services end can not be directly determined by micro services list for handling the first request
Third micro services example, and the 5th request is sent to the second micro services end, further increase the communication party between micro services end
Method diversity.
Second aspect, the embodiment of the present application provide communication device between a kind of micro services, comprising: determining module, for determining
For handling the second micro services end of the first request;Processing module determines described second for the micro services list according to acquisition
The first micro services example of first request is handled in micro services end;And the second request is sent to second micro services
It holds, includes the information of the information, first request and the first micro services example in second request.
In a kind of optional embodiment, the processing module is specifically used for: determining the response modes of first request;It presses
Second request is sent to second micro services end according to the response modes of first request.
In a kind of optional embodiment, the micro services list has indicated at least one of second micro services end
The micro services example of micro services and each micro services;The processing module is specifically used for: first micro services end is if it is determined that institute
Stating the first request is broadcast type, then first request is corresponded to all micro services of micro services in the micro services list
Example is as the first micro services example for handling first request.
In a kind of optional embodiment, the determining module is also used to: not determining first request for caching type and not
Cache the response contents of first request.
In a kind of optional embodiment, the determining module is also used to: if it is determined that first request for caching type and
The response contents for having cached first request then return to the response contents of first request and abandon first request.
In a kind of optional embodiment, the processing module is also used to: receiving third request, the third request is third
What micro services end was sent, include information, the 4th request and second micro services at third micro services end in the third request
The information of example;Pass through the 4th request described in the second micro services instance processes;If the response of the 4th request can be obtained
Content then sends the response contents of the 4th request to the third server-side.
In a kind of optional embodiment, the processing module is specifically used for: if the 4th request is Asynchronous Request, institute
It states and calls the first preset function processing the 4th request, and according to calling the result of first preset function to determine described the
The response contents of four requests whether there is;If the 4th request is synchronization request, the processing of the second preset function of the calling
4th request, and using the return value of second preset function as the response contents of the 4th request;Described second
Preset function is the function for having default return value.
In a kind of optional embodiment, the processing module is also used to: generating Feign client;The Feign client
For accessing the request receiver at second micro services end;The request receiver is access the first micro services example
Interface;By the Feign client, second request is sent to the request receiver, to connect by the request
It receives device and is sent to the first micro services example in second micro services end.
In a kind of optional embodiment, described device and second micro services end are deployed in Feign frame;Described device
It include HTTP interface with second micro services end;The processing module is also used to: according to http protocol, described second being asked
It asks and is sent to second micro services end.
In a kind of optional embodiment, the processing module is also used to: if it is determined that for handling first request
5th request is then sent to second micro services end by the third micro services example in second micro services end, and described the
It include information, the information of first request and the third micro services example at the first micro services end in five requests.
The beneficial effect of above-mentioned second aspect and each embodiment of second aspect can refer to above-mentioned first aspect and first
The beneficial effect of each embodiment of aspect, which is not described herein again.
The third aspect, the embodiment of the present application provide a kind of computer equipment, including program or instruction, when described program or refer to
Order is performed, the method to execute above-mentioned first aspect and each embodiment of first aspect.
Fourth aspect, the embodiment of the present application provides a kind of storage medium, including program or instruction, when described program or instruction
It is performed, the method to execute above-mentioned first aspect and each embodiment of first aspect.
Detailed description of the invention
Fig. 1 is the step flow diagram of communication means between a kind of micro services provided by the embodiments of the present application;
Fig. 2 is the applicable configuration diagram of communication means between a kind of micro services provided by the embodiments of the present application;
Fig. 3 is the applicable configuration diagram of communication means between a kind of micro services provided by the embodiments of the present application;
Fig. 4 is the structural schematic diagram of communication device between a kind of micro services provided by the embodiments of the present application.
Specific embodiment
In order to better understand the above technical scheme, below in conjunction with Figure of description and specific embodiment to above-mentioned
Technical solution is described in detail, it should be understood that the specific features in the embodiment of the present application and embodiment are to the application skill
The detailed description of art scheme, rather than the restriction to technical scheme, in the absence of conflict, the embodiment of the present application
And the technical characteristic in embodiment can be combined with each other.
For convenience of narration, the abbreviation and term occurred in the application is listed first.
Micro services: micro services are advocated single application procedure division into one group of small service, mutually coordinated, mutual between service
It matches, provides final value for user.Each micro services operate in its independent process, adopt between micro services and micro services
It is communicated with each other with the communication mechanism of lightweight.
Feign:Feign is a kind of statement formula, Templated hypertext transfer protocol (HyperText Transfer
Protocol, HTTP) client, Feign can more quickly call HTTP application programming interfaces (API).
Eureka:Eureka is a kind of service discovery framework, is in itself one and is transmitted based on declarative state
The service of (Representational State Transfer, REST), is mainly used for centre of the positioning trip in the domain AWS
Layer service, to achieve the purpose that middle layer service failover.Eureka is integrated in its sub-project by SpringCloud
In spring-cloud-netflix, to realize the service discovery function of SpringCloud.
In financial institution's (banking institution, insurance institution or security organization), in the business of progress, (loan transaction of such as bank is deposited
Money business etc.) in operation process, with the rise of micro services, for the interaction for realizing Financial Information, the micro services of financial business it
Between often have the demand being in communication with each other.
In the prior art, when a micro services are requested to another micro services transmission user, another can only be randomly choosed
The micro services example of micro services, and naturally isolated with Spring Cloud system, it can not coexist.For example, micro services one
Micro services example A sent to micro services two user request when, be some the micro services example for being sent to micro services two at random
B.Therefore the communication mode at present between micro services is more single, it is difficult to meet the business demand of diversified financial institution, Wu Fabao
Demonstrate,prove the high-efficiency operation of financial institution's items business.
For this purpose, the embodiment of the present application provides communication means between a kind of micro services.As shown in Figure 1, being mentioned for the embodiment of the present application
The step flow diagram of communication means between a kind of micro services supplied.
Step 101: the first micro services end determines the second micro services end for handling the first request.
Step 102: first micro services end determines in second micro services end according to the micro services list of acquisition
Manage the first micro services example of first request.
Step 103: the second request is sent to second micro services end by first micro services end.
It include information, first request and first micro services at first micro services end in second request
The information of example.
It should be noted that first micro services end and the second micro services end are that operation is micro- in step 101~step 103
The equipment of service, the micro services end that different micro services can be deployed in by micro services respectively are in communication with each other, each micro services end
In can run multiple micro services examples simultaneously.
The communication means between a kind of micro services end provided by the embodiments of the present application is discussed in detail below with reference to Fig. 2 and Fig. 3.Figure
2 and Fig. 3 is the applicable configuration diagram of communication means between a kind of micro services provided by the embodiments of the present application.
It is integrated into as shown in Fig. 2, Software Development Kit (Software Development Kit, SDK) can be provided
Among micro services in need.Fig. 2 shows micro services A and micro services B both can be used as request call side, can also be used as and ask
Ask recipient., will be by sender when as request call side, the recipient of request target recipient's micro services, as request
When recipient, it will be used to handle the request that request recipient sender sends over by recipient.Micro services A and micro services B
It provides service discovery module (illustrating by taking Eureka as an example in Fig. 2), periodic refreshing micro services situation of change.In Fig. 2 micro services A with
(illustrate) communication between micro services B for http protocol request in a predefined way.
As shown in figure 3, the first micro services end shown in Fig. 3 is transmitting terminal, second service end is receiving end.Shown based on Fig. 3
Framework out, step 101~step 103 integrated communication process can be such that
Step 101 is specifically as follows: the first micro services end determines the second micro services end for handling the first request.Here
Since the micro services that the second micro services end is run with it have binding relationship, the first micro services end is actually first to determine that request needs
The micro services to be sent determine the second micro services end further according to the binding relationship at micro services and the second micro services end.
It should be noted that the first micro services end can also directly determine the information of specific micro services example, micro services
The information of example may include IP address and the port of micro services name and micro services example.First micro services end passes through in step
The information of 101 specified micro services and/or micro services example obtains sender's transmitter, and sender's transmitter is used for will
First requests the software more bottom toward the first micro services end to transmit, and carries out subsequent step.
It, can be by blocking when the first micro services end sends the first request using sender's transmitter after step 101
It cuts device to intercept the first request, different blockers has different functions, to do at different functionalities the first request
Reason.First micro services end passes through request encoder again requests first after being converted into the data for meeting cannonical format.For example,
(entity B ean) is converted into the JSON character string of serializing.The data for meeting cannonical format are passed to Feign interface to generate
Device;Feign interface generator generates the Feign client that may have access to REST request receiver in the second micro services end.
In step 102, it should be noted that micro services list has indicated at least one of second micro services end in incognito
The micro services example of business and each micro services.The concrete form of micro services list can be the title of micro services and pragmatic in incognito
The list of example name set, for example, micro services tabular form can be with are as follows: micro services 1:{ micro services example 1, it is pragmatic in incognito
Example 2, micro services example 3 };Micro services 2:{ micro services example 1, micro services example 2, micro services example 3 }.Wherein, pragmatic in incognito
Example can mark health status, to indicate the operating status of micro services example, the second micro services that micro services list indicates
It is normal all micro services examples that at least one micro services example in end, which can be health status in the second micro services end,.The
At least one critical field is carried in one request, this at least one critical field can be used for advising according at least one preset matching
Then, from the micro services example of at least one micro services and each micro services that micro services list indicates, the first micro services are determined
Example.For example, critical field A and critical field B are carried in the first request, the value of critical field B in first interval,
The first preset matching rule at least one preset matching rule is that the request of carrying critical field A is matched with micro services A, because
This first request is corresponding with micro services A, and the second preset matching rule at least one preset matching rule is critical field
The value of B is matched in the request of first interval with the micro services example B in micro services A, so the first request is finally by micro services A
Micro services example B processing.
Step 102 is specifically as follows:
The micro services list that first micro services end is obtained according to Service Discovery Manager from service discovery module, and according to clothes
The pre-defined rule being engaged in selector determines the first micro services example that first request is handled in the second micro services end.Citing
For, it selects to load the smallest micro services example in all micro services examples of micro services.
Step 103 is specifically as follows:
When the first micro services end has determined specific micro services example in step 101~step 102, and generate
After Feign client, after the first request is encapsulated as the second request by Feign bottom by the first micro services end, it is sent to second
Micro services end.
In addition, after receiving the first request from first service end, treatment process is specific for second service end
It can be such that
After the REST request receiver at the second micro services end receives the first request, first call request decoder is asked to second
It asks and is decoded, it is pragmatic in incognito to parse in the information and the second micro services end of the first request and the first micro services end first
The information of example, and the information after parsing is put into request message queue.
The first request in the requesting consumption device meeting consumer requests message queue at the second micro services end, then received by calling
Person's manager obtains a suitable recipient, while the information at the first micro services end by getting, sender's generator
A sender is generated for the second micro services end, then by the first request and the sender generated, recipient is transmitted to and handles.
Illustrate the detailed communication process including a variety of possible situations in step 101~step 103 in conjunction with Fig. 3 below.
Before step 101, a kind of optional embodiment are as follows:
If first micro services end has determined the in second micro services end for handling first request
Three micro services examples, then the 5th request is sent to second micro services end, the 5th request by first micro services end
In include first micro services end information, it is described first request and the third micro services example information.
Under aforesaid way, the first micro services end can not be directly determined by micro services list for handling the first request
Third micro services example, and the 5th request is sent to the second micro services end, further increase the communication party between micro services end
Method diversity.
In step 102, additional functional processing can be done to the first request by the blocker shown in Fig. 3.In blocker
Can specifically include following several blockers: default blocker caches blocker, broadcasts blocker, retry blocker, is customized
Blocker.Wherein, default blocker is the outlet of blocker, for the step of jumping out blocker, goes to next processing step
Suddenly;Customized blocker provides custom rule editor's entrance, for realizing specific custom feature.Below with reference to tool
The optional embodiment of body is discussed in detail caching blocker, broadcasts blocker and retry blocker.
(a) it is considered as the content infrequently changed that caching blocker, which is for the response contents of some requests, such as personal
Date of birth information and set.Caching blocker can also provide special cache interface, if the first request realizes this
Cache interface can look for whether to have cached the corresponding response contents of the first request in caching blocker, first if there is then
It directly returns, otherwise continues following step, and after the second micro services end returning response content, first cache response contents
Get up, then response contents are returned into the first micro services end, is disposed.
A kind of optional embodiment that can be realized by caching blocker is as follows:
Before step 102, the first micro services end determines that first request is caching type and uncached described first asks
The response contents asked.Under aforesaid way, provides and determine that handle first request in second micro services end first is micro-
A kind of precondition of Service Instance, specific precondition are as follows: the first micro services end determine it is described first request for caching type and
The response contents of uncached first request.It should be noted that only illustrating the optional reality for caching blocker herein
A kind of situation of mode is applied, which can not also realize by caching blocker.
In addition, correspondingly, the first micro services end is if it is determined that first request is caching type and has cached described
The response contents of first request then return to the response contents of first request and abandon first request.Under aforesaid way,
First micro services end is not if it is determined that first request needs to cache type and having cached the described first response contents requested
The first request is sent, the response contents of the first request are directly returned and abandons first request, to further increase
Communication diversity, and which can save the communication resource.
(b) a kind of optional embodiment that can be realized by broadcast blocker is as follows:
In step 102, the micro services list indicated at least one micro services in second micro services end and
The micro services example of each micro services;It first micro services end, then will be described if it is determined that first request is broadcast type
First request correspond to that all micro services examples of micro services are requested as processing described first in the micro services list
One micro services example.
Specifically, broadcast blocker only comes into force to the request broadcasted.It is special that broadcast blocker can provide
Broadcast interface, if the first request realizes the broadcast interface, it is determined that the first request is broadcast type.When the shape of the first request
State label be not just in the broadcast when, broadcast blocker then think that the first request is broadcasted, at this moment can trigger setting-up exercises to music
Make.Specific steps are as follows: obtain first all micro services examples for being broadcasted of request, if it is it is empty then default be broadcast to the
All examples at two micro services ends;It then is in broadcast by request marks.It is available corresponding all micro- in step 103
All senders of Service Instance start to make requests transmission by way of multithreading;Until the sender in thread pool all
Request has been sent, this broadcast request is labeled as successfully, being disposed.
In the above method, it can be broadcast type by specified first request, realize and the first request is broadcast to second in incognito
The communication mode for all micro services examples being engaged in end.It should be noted that only illustrating that this can for broadcasting blocker herein
A kind of situation of embodiment is selected, the specific implementation of the optional embodiment is without limitation.
(c) retray function can be provided to all steps of first request after retrying blocker by retrying blocker.It can lead to
Cross retry blocker realization a kind of optional embodiment it is as follows:
If the first micro services end successfully transmits the first request, but the first micro services end return requirement retry it is different
Often, it at this moment can trigger and retry retrying for blocker, it is again automatic to submit the first request.If the first micro services end sends first and asks
Specific micro services example in not specified second micro services end, it is abnormal to there is connection when asking when sending request
(ConnectException), it also can actively be retried;Or can customize the Exception Type for needing to retry, it at this moment retries and blocks
Cutting device can also be retried automatically.
Before step 103, based on Feign interface generator and REST request receiver shown in Fig. 3 framework, Yi Zhongke
Select embodiment are as follows: the first micro services end generates Feign client;Specifically, the first micro services end can be raw by Feign interface
It grows up to be a useful person and generates Feign client.Wherein, the Feign client is used to access the request receiver at second micro services end.
The detailed process of step 103 can be with are as follows: second request is sent to by the first micro services end by the Feign client
The request receiver, it is pragmatic in incognito be sent in second micro services end by the request receiver described first
Example.The request receiver is the interface for accessing the first micro services example, is specifically as follows the REST request shown in Fig. 3 and connects
Receive device.
Under aforesaid way, the first micro services end generates Feign client, by the Feign client, by described second
Request is sent to the request receiver, to be sent to described the in second micro services end by the request receiver
One micro services example, to realize the communication means between the micro services end based on Feign client.
In a kind of optional embodiment of step 103, first micro services end and second micro services end are deployed in
Feign frame;First micro services end and second micro services end include HTTP interface;It presses at first micro services end
According to http protocol, second request is sent to second micro services end.
Under aforesaid way, the first micro services end and the second micro services end are deployed in Feign frame, are based on to realize
The micro services end sending method of Feign frame, moreover, because the first micro services end and the second micro services end connect including HTTP
Mouthful, the sending method based on http protocol may be implemented in the first micro services end, and the second request is sent to the second micro services end.
Another optional embodiment in step 103 is as follows:
First micro services end determines the response modes of first request;First micro services end is asked according to described first
Second request is sent to second micro services end by the response modes asked.
For example, the first response modes are synchronization request response modes, it is desirable that the second micro services end must synchronize return
Response;Second response modes method is synchronization request mode, is only responsible for synchronizing and requests to be sent to the second micro services end for first, no
It is required that the second micro services end provides response;Third response modes are Asynchronous Request mode, as long as the process at the second micro services end is not
Exception exits, and asynchronous the first request can be sent to the second micro services end by other threads.
In the above method, the first micro services end first determines the response modes of first request, sends out according still further to response modes
It send the second request to the second micro services end, increases the diversity of micro services end communication means so as to mode according to response.
In step 101~step 103 method, since the first micro services end has determined second for handling the first request
Micro services end, the first micro services end is according to the micro services list of acquisition, it is determined that the first request is handled in the second micro services end
First micro services example, thus before transmitting, it is determined that the micro services example that the second request will occur, and the first micro services
End directly by second request be sent to second micro services end, due to second request in include the first micro services end information,
The information of first request and the first micro services example, so that second service end can also know that the first micro services example is sent out
The specific micro services example of request is sent, the first micro services end may specify specific micro services example, increase micro services example
Selectivity, to improve the diversity that micro services end sends request.
After step 103, after second service termination receives the first request, first can be handled according to the framework shown in Fig. 3
Request.However, the first micro services end also can receive the request that other micro services ends are sent, and handle the process of request with
The process nature of the first request of second service end processing is identical, below from the angle at the first micro services end, introduces micro services reception
The process of end processing request.
In a kind of optional embodiment, first micro services end receives third request, and the third request is that third is micro-
What server-side was sent, information, the 4th request and described first in the third request including third micro services end are in incognito
The information for the second micro services example being engaged in end;Described in the second micro services instance processes in first micro services end
Four requests;If first micro services end can obtain the response contents of the 4th request, the sound of the 4th request is sent
Answer content to the third server-side.
Aforesaid way is the mode that the first micro services end receives third request, due to including third micro services in third request
Therefore the information of the information at end, the 4th request and the second micro services example in the first micro services end passes through third micro services end
The second specified micro services example handles the 4th request, and if the first micro services end energy in the first micro services end
The response contents for obtaining the 4th request then send the response contents of the 4th request to the third server-side, thus
Realize reception and processing that third is requested at the first micro services end.
In above-mentioned optional embodiment, described in the second micro services instance processes in first micro services end
Four requests can be with specifically: if the 4th request is Asynchronous Request, the first preset function is called at first micro services end
The 4th request is handled, and is according to the response contents for calling the result of first preset function to determine the 4th request
No presence;If the 4th request is synchronization request, the second preset function processing described the is called at first micro services end
Four requests, and using the return value of second preset function as the response contents of the 4th request;The second default letter
Number is the function for having default return value.
Under aforesaid way, it can be Asynchronous Request or synchronization request according to the 4th request, different preset functions is called to carry out
Processing, to obtain different response results, to further increase the communication diversity between micro services end.
Communication means advantage between a kind of micro services end provided by the embodiments of the present application is as follows:
(1) the micro services end in the embodiment of the present application can be exposed to micro services called side, micro services in a manner of sender
Called side only needs simply to specify micro services or specified micro services example (to can be realized and target micro services some example/refer to
Determine the access between example/whole example (broadcasting).
(2) micro services recipient is exposed in a manner of recipient, it is desirable that micro services recipient realizes micro services called side
Synchronization request and Asynchronous Request.Synchronization request requires recipient to immediately access request results, and Asynchronous Request is then responsible for will request
The sender of information and called side passes to recipient, and micro services recipient can pass through the sender of direction micro services called side
Asynchronous passback response results.
(3) Spring Cloud system is got through, integrated service discovery is defaulted, Dynamic Discovery can be newly added in incognito in real time
Business realizes that dynamic forwards.
(4) communication plan of the complex rule between micro services is realized based on Feign.
As shown in figure 4, providing communication device between a kind of micro services for the embodiment of the present application, comprising: determining module 401 is used
It is used to handle the first the second micro services end requested in determining;Processing module 402, for the micro services list according to acquisition, really
The first micro services example of first request is handled in fixed second micro services end;And the second request is sent to described
Second micro services end includes the information, first request and the first micro services example in second request
Information.
In a kind of optional embodiment, the processing module 402 is specifically used for: determining the response mould of first request
Formula;Second request is sent to second micro services end according to the response modes of first request.
In a kind of optional embodiment, the micro services list has indicated at least one of second micro services end
The micro services example of micro services and each micro services;The processing module 402 is specifically used for: if it is determined that first request is wide
Type is broadcast, then first request is corresponded into all micro services examples of micro services as processing institute in the micro services list
State the first micro services example of the first request.
In a kind of optional embodiment, the determining module 401 is also used to: determine first request for caching type and
The response contents of uncached first request.
In a kind of optional embodiment, the determining module 401 is also used to: if it is determined that first request is caching type
And cached the response contents of first request, then it returns to the response contents of first request and abandons described first and ask
It asks.
In a kind of optional embodiment, the processing module 402 is also used to: receiving third request, the third request is
What third micro services end was sent, the information, the 4th request and second in the third request including third micro services end are micro-
The information of Service Instance;Pass through the 4th request described in the second micro services instance processes;If the 4th request can be obtained
Response contents then send the response contents of the 4th request to the third server-side.
In a kind of optional embodiment, the processing module 402 is specifically used for: if the 4th request is Asynchronous Request,
Then the first preset function of calling processing the 4th request, and institute is determined according to the result of calling first preset function
The response contents for stating the 4th request whether there is;If the 4th request is synchronization request, the second preset function of the calling
The 4th request is handled, and using the return value of second preset function as the response contents of the 4th request;It is described
Second preset function is the function for having default return value.
In a kind of optional embodiment, the processing module 402 is also used to: generating Feign client;The Feign visitor
Family end is used to access the request receiver at second micro services end;The request receiver is that access described first is pragmatic in incognito
The interface of example;By the Feign client, second request is sent to the request receiver, to ask by described
Receiver is asked to be sent to the first micro services example in second micro services end.
In a kind of optional embodiment, described device and second micro services end are deployed in Feign frame;Described device
It include HTTP interface with second micro services end;The processing module 402 is also used to: according to http protocol, by described
Two requests are sent to second micro services end.
In a kind of optional embodiment, the processing module 402 is also used to: if it is determined that for handling first request
Second micro services end in third micro services example, then by the 5th request be sent to second micro services end, it is described
It include information, the information of first request and the third micro services example at the first micro services end in 5th request.
The embodiment of the present application provides a kind of computer equipment, including program or instruction, when described program or instruction are performed
When, to execute communication means and any optional method between a kind of micro services provided by the embodiments of the present application.
The embodiment of the present application provides a kind of storage medium, including program or instruction, when described program or instruction be performed,
To execute communication means and any optional method between a kind of micro services provided by the embodiments of the present application.
Finally, it should be noted that it should be understood by those skilled in the art that, embodiments herein can provide as method, be
System or computer program product.Therefore, the application can be used complete hardware embodiment, complete software embodiment or combine software
With the form of the embodiment of hardware aspect.Moreover, it wherein includes that computer can use journey that the application, which can be used in one or more,
The computer implemented in the computer-usable storage medium (including but not limited to magnetic disk storage, optical memory etc.) of sequence code
The form of program product.
The application be referring to according to the present processes, equipment (system) and computer program product flow chart and/or
Block diagram describes.It should be understood that each process that can be realized by computer program instructions in flowchart and/or the block diagram and/or
The combination of process and/or box in box and flowchart and/or the block diagram.It can provide these computer program instructions to arrive
General purpose computer, special purpose computer, Embedded Processor or other programmable data processing devices processor to generate one
Machine, so that being generated by the instruction that computer or the processor of other programmable data processing devices execute for realizing flowing
The device for the function of being specified in journey figure one process or multiple processes and/or block diagrams one box or multiple boxes.
These computer program instructions, which may also be stored in, is able to guide computer or other programmable data processing devices with spy
Determine in the computer-readable memory that mode works, so that it includes referring to that instruction stored in the computer readable memory, which generates,
Enable the manufacture of device, the command device realize in one box of one or more flows of the flowchart and/or block diagram or
The function of being specified in multiple boxes.
Obviously, those skilled in the art can carry out various modification and variations without departing from the model of the application to the application
It encloses.In this way, if these modifications and variations of the application belong within the scope of the claim of this application and its equivalent technologies, then
The application is also intended to include these modifications and variations.
Claims (12)
1. communication means between a kind of micro services characterized by comprising
First micro services end determines the second micro services end for handling the first request;
First micro services end determines that described first is handled in second micro services end asks according to the micro services list of acquisition
The the first micro services example asked;
Second request is sent to second micro services end by first micro services end, includes described the in second request
The information at one micro services end, the information of first request and the first micro services example.
2. the method as described in claim 1, which is characterized in that the second request is sent to described the by first micro services end
Two micro services ends, comprising:
First micro services end determines the response modes of first request;
According to the response modes of first request, by second request, to be sent to described second micro- at first micro services end
Server-side.
3. the method as described in claim 1, which is characterized in that the micro services list has indicated second micro services end
In at least one micro services and each micro services micro services example;First micro services end is arranged according to the micro services of acquisition
Table determines the first micro services example that first request is handled in second micro services end, comprising:
First micro services end is if it is determined that first request is broadcast type, then by first request in the micro services
All micro services examples of micro services are corresponded in list as the first micro services example for handling first request.
4. the method as described in claim 1, which is characterized in that first micro services end according to the micro services list of acquisition,
It determines before handling the first micro services example that described first requests in second micro services end, further includes:
First micro services end determines first request for caching type and the response contents of uncached first request.
5. the method as described in claim 1, which is characterized in that further include:
First micro services end is if it is determined that first request is caching type and has cached in the response that described first requests
Hold, then return to the response contents of first request and abandons first request.
6. method a method as claimed in any one of claims 1 to 5, which is characterized in that further include:
First micro services end receives third request, and the third request is that third micro services end is sent, and the third is asked
Ask information including third micro services end, the 4th request and the second micro services example in first micro services end
Information;
4th request described in the second micro services instance processes in first micro services end;
If first micro services end can obtain the response contents of the 4th request, in the response for sending the 4th request
Hold to the third server-side.
7. method as claimed in claim 6, which is characterized in that the second micro services example in first micro services end
Handle the 4th request, comprising:
If the 4th request is Asynchronous Request, first micro services end calls the first preset function processing the described 4th to ask
It asks, and whether there is according to the response contents for calling the result of first preset function to determine that the described 4th requests;
If the 4th request is synchronization request, first micro services end calls the second preset function processing the described 4th to ask
It asks, and using the return value of second preset function as the response contents of the 4th request;Second preset function is
There is the function of default return value.
8. method a method as claimed in any one of claims 1 to 5, which is characterized in that the second request is sent to by first micro services end
Before second micro services end, further includes:
First micro services end generates Feign client;The Feign client is for accessing second micro services end
Request receiver;The request receiver is the interface for accessing the first micro services example;
Second request is sent to second micro services end by first micro services end, comprising:
First micro services end is sent to the request receiver by the Feign client, by second request, with
The the first micro services example being sent to by the request receiver in second micro services end.
9. method a method as claimed in any one of claims 1 to 5, which is characterized in that first micro services end and second micro services
End is deployed in Feign frame;First micro services end and second micro services end include HTTP interface;
Second request is sent to second micro services end by first micro services end, comprising:
First micro services end is sent to second micro services end according to http protocol, by second request.
10. method a method as claimed in any one of claims 1 to 5, which is characterized in that first micro services end according to acquisition in incognito
Business list determines before handling the first micro services example that described first requests in second micro services end, further includes:
If first micro services end has determined that the third in second micro services end for handling first request is micro-
Service Instance, then the 5th request is sent to second micro services end by first micro services end, is wrapped in the 5th request
Include the information at first micro services end, the information of first request and the third micro services example.
11. a kind of computer equipment, which is characterized in that including program or instruction, when described program or instruction are performed, as weighed
Benefit require any one of 1 to 10 described in method be performed.
12. a kind of storage medium, which is characterized in that including program or instruction, when described program or instruction are performed, such as right
It is required that method described in any one of 1 to 10 is performed.
Priority Applications (2)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201910655479.5A CN110377437A (en) | 2019-07-19 | 2019-07-19 | Communication means, computer equipment and storage medium between a kind of micro services |
PCT/CN2020/102224 WO2021013023A1 (en) | 2019-07-19 | 2020-07-15 | Microservice inter-communication method, computer apparatus, and storage medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201910655479.5A CN110377437A (en) | 2019-07-19 | 2019-07-19 | Communication means, computer equipment and storage medium between a kind of micro services |
Publications (1)
Publication Number | Publication Date |
---|---|
CN110377437A true CN110377437A (en) | 2019-10-25 |
Family
ID=68254212
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201910655479.5A Pending CN110377437A (en) | 2019-07-19 | 2019-07-19 | Communication means, computer equipment and storage medium between a kind of micro services |
Country Status (2)
Country | Link |
---|---|
CN (1) | CN110377437A (en) |
WO (1) | WO2021013023A1 (en) |
Cited By (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN112202929A (en) * | 2020-12-01 | 2021-01-08 | 湖南新云网科技有限公司 | Service access method, device and equipment in micro-service architecture |
WO2021013023A1 (en) * | 2019-07-19 | 2021-01-28 | 深圳前海微众银行股份有限公司 | Microservice inter-communication method, computer apparatus, and storage medium |
CN112799803A (en) * | 2021-01-14 | 2021-05-14 | 深圳市瞬点科技有限公司 | Micro-service architecture operation maintenance method, device, equipment and readable storage medium |
CN112988405A (en) * | 2019-12-02 | 2021-06-18 | 中国移动通信集团浙江有限公司 | Micro-service automatic degradation method and device and computing equipment |
CN113094398B (en) * | 2021-04-20 | 2024-04-05 | 深圳力维智联技术有限公司 | Data link tracking method based on block chain technology |
Family Cites Families (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US10268566B2 (en) * | 2016-11-04 | 2019-04-23 | Sap Se | Debugging in a private cloud environment |
CN109995713B (en) * | 2017-12-30 | 2020-11-27 | 华为技术有限公司 | Service processing method in micro-service framework and related equipment |
CN108234666A (en) * | 2018-01-16 | 2018-06-29 | 云宏信息科技股份有限公司 | A kind of micro services calling system, method and computer storage media |
CN110381058B (en) * | 2019-07-18 | 2023-05-16 | 深圳前海微众银行股份有限公司 | Request transmission method and device based on full duplex communication protocol WebSocket |
CN110377437A (en) * | 2019-07-19 | 2019-10-25 | 深圳前海微众银行股份有限公司 | Communication means, computer equipment and storage medium between a kind of micro services |
-
2019
- 2019-07-19 CN CN201910655479.5A patent/CN110377437A/en active Pending
-
2020
- 2020-07-15 WO PCT/CN2020/102224 patent/WO2021013023A1/en active Application Filing
Cited By (8)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
WO2021013023A1 (en) * | 2019-07-19 | 2021-01-28 | 深圳前海微众银行股份有限公司 | Microservice inter-communication method, computer apparatus, and storage medium |
CN112988405A (en) * | 2019-12-02 | 2021-06-18 | 中国移动通信集团浙江有限公司 | Micro-service automatic degradation method and device and computing equipment |
CN112988405B (en) * | 2019-12-02 | 2023-12-26 | 中国移动通信集团浙江有限公司 | Automatic degradation method and device for micro-service and computing equipment |
CN112202929A (en) * | 2020-12-01 | 2021-01-08 | 湖南新云网科技有限公司 | Service access method, device and equipment in micro-service architecture |
CN112202929B (en) * | 2020-12-01 | 2021-03-26 | 湖南新云网科技有限公司 | Service access method, device and equipment in micro-service architecture |
CN112799803A (en) * | 2021-01-14 | 2021-05-14 | 深圳市瞬点科技有限公司 | Micro-service architecture operation maintenance method, device, equipment and readable storage medium |
CN112799803B (en) * | 2021-01-14 | 2023-11-17 | 深圳市瞬点科技有限公司 | Micro-service architecture operation maintenance method, device, equipment and readable storage medium |
CN113094398B (en) * | 2021-04-20 | 2024-04-05 | 深圳力维智联技术有限公司 | Data link tracking method based on block chain technology |
Also Published As
Publication number | Publication date |
---|---|
WO2021013023A1 (en) | 2021-01-28 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN110377437A (en) | Communication means, computer equipment and storage medium between a kind of micro services | |
EP1719288B1 (en) | System and method for communicating asynchronously with web services using message set definitions | |
KR100889977B1 (en) | Media session framework using protocol independent control module to direct and manage application and service servers | |
CN103491135B (en) | Device and method for conducting self-matching on data formats | |
US10038762B2 (en) | Request and response decoupling via pluggable transports in a service oriented pipeline architecture for a request response message exchange pattern | |
CN101322385B (en) | Method and system of load balancing and failover of distributed media resources in a media server | |
CN105763619B (en) | The method and device that client and server-side are communicated | |
CN106797400A (en) | System and method for making it possible to access third party's service via service layer | |
CN101296176B (en) | Data processing method and apparatus based on cluster | |
CN111212085A (en) | Internet of things platform synchronous calling method, Internet of things system and network equipment | |
CN101640736B (en) | Method and system for realizing visual customer service | |
CN109189502A (en) | A kind of message treatment method and relevant device based on instant messaging public platform | |
CN108696899A (en) | Sip message transmits and method of reseptance and transmission and reception device | |
US8103759B2 (en) | Message redirection within a messaging infrastructure | |
CN103248654A (en) | Negotiation method, device and system for virtual desktop service parameters | |
CN108965359A (en) | Communication means, communication device, readable medium and electronic equipment | |
CN110381058A (en) | Request transmission method and device based on full-duplex communication protocol Web Socket | |
US7487510B1 (en) | Method and apparatus to isolate changes in remoting system clients | |
CN104969533B (en) | A kind of data package processing method and device | |
US7475402B1 (en) | Method and apparatus to isolate changes in remoting system servers | |
KR20090042542A (en) | Method for collecting quality data of web service using dummy message | |
US20090300212A1 (en) | Heuristics processing | |
JP3926306B2 (en) | Workflow interworking apparatus, program thereof, and workflow processing method | |
CN114416404A (en) | Remote procedure calling method and device | |
CN116389615A (en) | Dual-protocol information transmission method, device and equipment based on same port |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination |