CN114428737A - Communication method, device, equipment and storage medium based on micro service system - Google Patents

Communication method, device, equipment and storage medium based on micro service system Download PDF

Info

Publication number
CN114428737A
CN114428737A CN202210080747.7A CN202210080747A CN114428737A CN 114428737 A CN114428737 A CN 114428737A CN 202210080747 A CN202210080747 A CN 202210080747A CN 114428737 A CN114428737 A CN 114428737A
Authority
CN
China
Prior art keywords
service
target
communication request
micro
response information
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
Application number
CN202210080747.7A
Other languages
Chinese (zh)
Inventor
王凯
于海涛
于凯敏
范磊
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Agricultural Bank of China
Original Assignee
Agricultural Bank of China
Priority date (The priority date 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 date listed.)
Filing date
Publication date
Application filed by Agricultural Bank of China filed Critical Agricultural Bank of China
Priority to CN202210080747.7A priority Critical patent/CN114428737A/en
Publication of CN114428737A publication Critical patent/CN114428737A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3664Environments for testing or debugging software
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3668Software testing
    • G06F11/3672Test management
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/10File systems; File servers
    • G06F16/17Details of further file system functions
    • G06F16/172Caching, prefetching or hoarding of files
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements 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/46Multiprogramming arrangements
    • G06F9/48Program initiating; Program switching, e.g. by interrupt
    • G06F9/4806Task transfer initiation or dispatching
    • G06F9/4843Task transfer initiation or dispatching by program, e.g. task dispatcher, supervisor, operating system
    • G06F9/4881Scheduling strategies for dispatcher, e.g. round robin, multi-level priority queues

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Computer Hardware Design (AREA)
  • Quality & Reliability (AREA)
  • Software Systems (AREA)
  • Data Mining & Analysis (AREA)
  • Databases & Information Systems (AREA)
  • Information Transfer Between Computers (AREA)

Abstract

The application provides a communication method, a device, equipment and a storage medium based on a micro-service system, wherein a communication request sent by a target micro-service is received, and the communication request is used for calling an external service; determining a corresponding target file according to the communication request, wherein the target file is stored locally and is used for bearing first response information returned by the external service; and obtaining a target message according to the target file, and sending the target message to the target micro service, wherein the target message contains first response information and is used for responding a communication request sent by the target micro service. When the target micro-service calls the external service through the communication request, the communication request is responded through the corresponding target file, so that the simulation of the external service called by the target micro-service from the outside is realized, a plug-in function does not need to be arranged in the target micro-service for calling simulation, the efficiency of the application testing and debugging process is improved, and the application safety is improved.

Description

Communication method, device, equipment and storage medium based on micro service system
Technical Field
The present application relates to the field of internet technologies, and in particular, to a communication method, apparatus, device, and storage medium based on a micro service system.
Background
A microservice is a software development technology, which is a variant of a Service-Oriented Architecture (SOA) architectural style, and implements corresponding functions by dividing a single application into a set of small services and by coordinating and cooperating the services with each other. Each service is built around a specific business and can be deployed independently to a production environment, a production-like environment, and the like. Currently, in banking, many customer-oriented applications are developed based on microservices architecture.
In the prior art, in the process of debugging and testing an application under a micro-service system, because the normal function operation of a target service in the application needs to be based on the call of an external service, a corresponding call code needs to be embedded in the target service in advance to realize the simulated call of the external service, and the problem of low testing and debugging efficiency and poor application safety is caused by the mode of debugging and testing the application.
Disclosure of Invention
The application provides a communication method, a communication device, communication equipment and a storage medium based on a micro-service system, which are used for solving the problems of low testing and debugging efficiency and poor application safety caused by embedding a corresponding calling code to perform external service simulation.
In a first aspect, the present application provides a communication method based on a microservice system, including:
receiving a communication request sent by a target micro service, wherein the communication request is used for calling an external service; determining a corresponding target file according to the communication request, wherein the target file is stored locally and is used for bearing first response information returned by the external service; and obtaining a target message according to the target file, and sending the target message to the target micro service, wherein the target message comprises the first response information, and the target message is used for responding to a communication request sent by the target micro service.
In a possible implementation manner, determining a corresponding target file according to the communication request includes: analyzing the communication request to obtain a service identifier, wherein the service identifier represents the target banking service; and determining a corresponding target file according to the service identifier.
In a possible implementation manner, determining a corresponding target file according to the service identifier includes: determining service scene information according to the service identification, wherein the service scene information represents a target service process corresponding to the target banking service; and determining the target file based on the service scene information, wherein the target file is used for bearing first response information returned by the external service corresponding to the target service process.
In a possible implementation manner, the service identifier includes a service node identifier, and the service node identifier represents one service node in a corresponding service flow; determining the target file based on the service scenario information, including: determining a corresponding target service node according to the service node identifier; and determining a corresponding target file according to the target service node, wherein the target file is used for bearing first response information returned by the external service corresponding to the target service node.
In one possible implementation, receiving a communication request sent by a target microservice includes: running a baffle service corresponding to the target micro service, wherein the baffle service is a project object model dependency of the target micro service; and receiving the communication request sent by the target micro service through the baffle service.
In one possible implementation, before receiving the communication request sent by the target micro-service, the method further includes: acquiring second response information returned by the external service; analyzing the second response information to obtain service scene information corresponding to the second response information, wherein the service scene information represents a target service process corresponding to banking services; and classifying and storing the second response information according to the service scene information to generate an alternative file corresponding to a target service process, wherein the alternative file is used for bearing the second response information corresponding to the target service process.
In a possible implementation manner, after generating the candidate file corresponding to the target business process, the method further includes: acquiring calling frequencies corresponding to different external services within a first time period; and deleting the alternative files corresponding to the external services with the calling frequency less than the frequency threshold value according to the calling frequency corresponding to each external service.
In a second aspect, the present application provides a communication device based on a micro service architecture, including:
the receiving module is used for receiving a communication request sent by a target micro-service, and the communication request is used for calling an external service;
the processing module is used for determining a corresponding target file according to the communication request and obtaining a target message according to the target file, wherein the target file is stored locally and is used for bearing first response information returned by the external service;
and the sending module is used for sending the target message to the target micro service, wherein the target message comprises the first response information, and the target message is used for responding to a communication request sent by the target micro service.
In a possible implementation manner, when determining the corresponding target file according to the communication request, the processing module is specifically configured to: analyzing the communication request to obtain a service identifier, wherein the service identifier represents the target banking service; and determining a corresponding target file according to the service identifier.
In a possible implementation manner, when determining the corresponding target file according to the service identifier, the processing module is specifically configured to: determining service scene information according to the service identification, wherein the service scene information represents a target service process corresponding to the target banking service; and determining the target file based on the service scene information, wherein the target file is used for bearing first response information returned by the external service corresponding to the target service process.
In a possible implementation manner, the service identifier includes a service node identifier, and the service node identifier represents one service node in a corresponding service flow; the processing module, when determining the target file based on the service context information, is specifically configured to: determining a corresponding target service node according to the service node identifier; and determining a corresponding target file according to the target service node, wherein the target file is used for bearing first response information returned by the external service corresponding to the target service node.
In a possible implementation manner, the receiving module is specifically configured to: running a baffle service corresponding to the target micro service, wherein the baffle service is a project object model dependency of the target micro service; and receiving the communication request sent by the target micro service through the baffle service.
In a possible implementation manner, before receiving the communication request sent by the target micro-service, the processing module is further configured to: acquiring second response information returned by the external service; analyzing the second response information to obtain service scene information corresponding to the second response information, wherein the service scene information represents a target service process corresponding to banking services; and classifying and storing the second response information according to the service scene information to generate an alternative file corresponding to a target service process, wherein the alternative file is used for bearing the second response information corresponding to the target service process.
In a possible implementation manner, after generating the candidate file corresponding to the target business process, the processing module is further configured to: acquiring calling frequencies corresponding to different external services within a first time period; and deleting the alternative files corresponding to the external services with the calling frequency less than the frequency threshold according to the calling frequency corresponding to each external service.
In a third aspect, the present application provides an electronic device, comprising: a processor, and a memory communicatively coupled to the processor;
the memory stores computer-executable instructions;
the processor executes the computer-executable instructions stored in the memory to implement the communication method based on the micro service system according to any one of the first aspect of the embodiments of the present application.
In a fourth aspect, the present application provides a computer-readable storage medium, in which computer-executable instructions are stored, and when the computer-executable instructions are executed by a processor, the computer-readable storage medium is configured to implement the micro service architecture-based communication method according to any one of the first aspect of the embodiments of the present application.
According to a fifth aspect of embodiments herein, there is provided a computer program product comprising a computer program which, when executed by a processor, implements the microservices architecture based communication method as described in any one of the first aspects above.
According to the communication method, the communication device, the communication equipment and the storage medium based on the micro-service system, a communication request sent by a target micro-service is received, and the communication request is used for calling an external service; determining a corresponding target file according to the communication request, wherein the target file is stored locally and is used for bearing first response information returned by the external service; and obtaining a target message according to the target file, and sending the target message to the target micro service, wherein the target message comprises the first response information, and the target message is used for responding to a communication request sent by the target micro service. When the target micro service calls the external service through the communication request, the target micro service generates a target message comprising first response information through the corresponding target file, returns the target micro service and responds to the communication request, so that the simulation of the external service called by the target micro service from the outside is realized, a plug-in function does not need to be arranged in the target micro service for calling simulation, the efficiency of the application test and debugging process is improved, and the application safety is improved.
Drawings
The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and together with the description, serve to explain the principles of the application.
FIG. 1 is a schematic structural diagram of a microserver architecture provided in an embodiment of the present application;
FIG. 2 is a flow chart of a communication method based on a micro service architecture according to an embodiment of the present application;
FIG. 3 is a schematic diagram illustrating a specific implementation step of step S101 in the embodiment shown in FIG. 2;
FIG. 4 is a diagram illustrating a specific implementation step of step S102 in the embodiment shown in FIG. 2;
FIG. 5 is a flowchart of a communication method based on a microservice architecture according to another embodiment of the present application;
fig. 6 is a schematic diagram of a process of generating an alternative file according to an embodiment of the present application;
FIG. 7 is a diagram illustrating a specific implementation step of step S207 in the embodiment shown in FIG. 5;
fig. 8 is a schematic structural diagram of a communication device based on a micro service architecture according to an embodiment of the present application;
FIG. 9 is a schematic view of an electronic device provided by an embodiment of the present application;
fig. 10 is a block diagram of a terminal device according to an exemplary embodiment of the present application.
With the above figures, there are shown specific embodiments of the present application, which will be described in more detail below. The drawings and written description are not intended to limit the scope of the inventive concepts in any manner, but rather to illustrate the concepts of the application by those skilled in the art with reference to specific embodiments.
Detailed Description
Reference will now be made in detail to the exemplary embodiments, examples of which are illustrated in the accompanying drawings. When the following description refers to the accompanying drawings, like numbers in different drawings represent the same or similar elements unless otherwise indicated. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present application. Rather, they are merely examples of apparatus and methods consistent with certain aspects of the present application, as detailed in the appended claims.
In the technical scheme of the application, the collection, storage, use, processing, transmission, provision, disclosure and other processing of the personal information and the financial data of the related user are all in accordance with the regulations of related laws and regulations and do not violate the good customs of the public order.
The following explains an application scenario of the embodiment of the present application:
fig. 1 is a schematic structural diagram of a micro service system provided in an embodiment of the present application, where the communication method of the micro service system provided in the embodiment of the present application may be applied to a scenario for testing an application program in the micro service system, for example, as shown in fig. 1, a target micro service corresponding to a target application is deployed in a target server, and the target micro service is used to implement one or more functions of the target application. Under the micro-service system, the target micro-service communicates with external services deployed in other servers through a network, and corresponding application functions are realized by calling the external services. The execution main body of the method provided by the embodiment of the application can be terminal equipment, the terminal equipment is in communication connection with the target server, and the method provided by the embodiment is executed on one side of the terminal equipment to provide virtual external services for the target micro-service deployed in the target server, so that the target micro-service and the corresponding application program can be tested.
In the prior art, in the process of debugging and testing an application under a micro-service system, since the normal function operation of a target service in the application needs to be based on the call of an external service, in order to better implement the test and debugging of the target micro-service, a corresponding call code needs to be embedded in a program corresponding to the target micro-service in advance, for example, a plug-in function is set, so as to implement the simulated call of the external service. However, when the target micro service is debugged and tested in this way, instrumentation needs to be performed in a program corresponding to the target micro service, and when the called external service changes, the formats of instrumentation points and instrumentation functions in the program also need to be correspondingly adjusted, which results in a problem of low testing and debugging efficiency; meanwhile, after the target micro-service is debugged, the stub function in the target micro-service needs to be deleted to ensure that the external service can be normally called after the target micro-service is online, and if the stub function is not deleted, the target micro-service may not obtain normal communication data, which affects the program function and the application security.
The following describes the technical solutions of the present application and how to solve the above technical problems with specific embodiments. The following several specific embodiments may be combined with each other, and details of the same or similar concepts or processes may not be repeated in some embodiments. Embodiments of the present application will be described below with reference to the accompanying drawings.
Fig. 2 is a flowchart of a communication method based on a micro service architecture according to an embodiment of the present application, and as shown in fig. 2, the communication method based on the micro service architecture according to the embodiment includes the following steps:
step S101, receiving a communication request sent by a target micro service, wherein the communication request is used for calling an external service.
For example, the executing body of the method of this embodiment may be a terminal device, and the target micro service is used to provide specific functions for a user accessing the micro service, such as user login, account inquiry, fund transaction, and the like. And the terminal equipment is used for providing virtual external services for the target micro-service. In one possible implementation manner, the terminal device is communicated with a target server deployed with a target micro service, and receives communication information sent by the target server to provide simulated external services for the target micro service; in another possible implementation manner, the target micro service runs in the terminal device, and the terminal device obtains the communication request sent by the target micro service through a corresponding process, so as to provide a simulated external service for the target micro service.
Further, exemplarily, in the terminal device, a baffle service for providing a simulated external service for the target micro service is deployed, and the baffle service is a Project Object Model (POM) dependency of the target micro service. The project object model is a basic work unit of the Maven project, and is usually a file based on an XML format. It contains basic information of the project, describing how the project is constructed, declaring project dependencies, etc. When a task or a target is executed, Maven searches an item object model in a current directory, reads the item object model, acquires required configuration information, and then executes the target.
The baffle service is an item object model dependency of the target micro service, which means that a baffle service module is added into a micro service module needing to provide the baffle service in a Maven POM dependent mode. Providing a baffle service mechanism for the target micro-service in the development and debugging process; the baffle service module and the service micro-service module form a system, and the two modules are related together in a POM (point of sale) dependent mode.
Based on the above description, as shown in fig. 3, the implementation step of step S101 includes:
step S1011, the baffle service corresponding to the target micro service is operated, and the baffle service is the item object model dependency of the target micro service.
Step S1012 receives a communication request sent by the target microservice through the barrier service.
In a possible implementation manner, after the target micro service is operated, the corresponding baffle service is also operated, and a communication request sent by the target micro service is received, in the subsequent steps, the baffle service responds based on the communication request, and finally returns a target message corresponding to the communication request to the target micro service, so as to provide a virtual external service for the target micro service. The communication between the baffle service and the target micro service is realized through a corresponding communication interface, and the data communication realization process between the services is the prior art known by those skilled in the art, which is not described herein again.
And step S102, determining a corresponding target file according to the communication request, wherein the target file is stored locally and is used for bearing first response information returned by the external service.
Illustratively, after the terminal device receives the communication request, in order to provide the corresponding virtual external service to the target micro service, first response information which can be received by the target micro service and is used as a response to the communication request needs to be generated based on the communication request. Wherein, the object file is the carrier carrying the first response information. Specifically, the communication request includes service information capable of representing a specific banking service, and the banking service corresponding to the service information is determined by analyzing and extracting the service information in the communication request. In a possible implementation manner, the banking business and the target file have a preset mapping relationship, and the target file corresponding to the business information can be determined according to the mapping relationship.
Illustratively, as shown in fig. 4, the specific implementation steps of step S102 include:
and step S1021, the communication request is analyzed to obtain a service identifier, and the service identifier represents the target banking service.
Step S1022, determining a corresponding target file according to the service identifier.
Specifically, the service identifier is service information representing a target banking service, for example, a service identifier #001 is obtained by analyzing a communication request, the target banking service represented by the service identifier #001 is a user account login, and a target file corresponding to the service identifier #001 is a file 001 through a preset mapping table; for another example, by parsing the communication request, a service identifier #002 is obtained, the target banking service represented by the service identifier #002 is a user account, and through a preset mapping table, a target file corresponding to the service identifier #002 is a file 002.
And step S103, obtaining a target message according to the target file, and sending the target message to the target micro service, wherein the target message contains first response information and is used for responding to a communication request sent by the target micro service.
For example, the object file may be regarded as a carrier for carrying first response information, and after obtaining the object file, the first response information in the object file needs to be extracted and processed, and encoding of a response is performed, so as to generate a message that can be received and identified by the target microservice, that is, an object message. The target message comprises corresponding information, and after the target micro-service receives the target message, the target micro-service can analyze the target message to obtain first response information in the target message. The process can be regarded as simulation of truly calling external services for the target micro service, and a target message obtained by the target micro service is the same as a response message obtained by truly accessing the external services of other servers under the micro service system, so that the aim of simulating a real environment to test the function of the target micro service can be fulfilled. Compared with the scheme of testing through an embedded stub function code in the prior art, the method saves the time for writing the stub function, and simultaneously provides a simulated response to the target micro service from the outside of the target micro service, so that the method is closer to a real online environment, the effectiveness of the function test for calling the external function of the target micro service is improved, and the stability and the safety of the application program are further improved.
In the embodiment, by receiving a communication request sent by a target micro service, the communication request is used for calling an external service; determining a corresponding target file according to the communication request, wherein the target file is stored locally and is used for bearing first response information returned by the external service; and obtaining a target message according to the target file, and sending the target message to the target micro service, wherein the target message contains first response information and is used for responding a communication request sent by the target micro service. When the target micro service calls the external service through the communication request, the target micro service generates a target message comprising first response information through the corresponding target file, returns the target micro service and responds to the communication request, so that the simulation of the external service called by the target micro service from the outside is realized, a plug-in function does not need to be arranged in the target micro service for calling simulation, the efficiency of the application test and debugging process is improved, and the application safety is improved.
Fig. 5 is a flowchart of a communication method based on a micro service system according to another embodiment of the present application, and as shown in fig. 5, the communication method based on a micro service system according to this embodiment further refines step S102 on the basis of the communication method based on a micro service system according to the embodiment shown in fig. 2, and adds a process of recording a target file, so that the communication method based on a micro service system according to this embodiment includes the following steps:
step S201, acquiring second response information returned by the external service.
Step S202, the second response information is analyzed to obtain business scenario information corresponding to the second response information, and the business scenario information represents a target business process corresponding to the banking business.
Step S203, classifying and saving the second response information according to the service scene information, and generating an alternative file corresponding to the target service process, where the alternative file is used to carry the second response information corresponding to the target service process.
Illustratively, the second response information is response information returned by the external service when the external service is actually called, that is, the target microservice sends a communication request through the network to call the external service, and the external service returns the second response information to the target microservice through the network after receiving the communication request to respond to the request of the target microservice. After receiving second response information returned by the external service, the terminal device obtains corresponding information representing banking business, such as business scene information representing a target business process of the banking business, by analyzing the second response information. The service context information corresponding to the second response information may be understood as an implementation method of the content in the second response information. The target micro service associates a plurality of external services, and when the target micro service sends a communication request to different external services to call the corresponding external services, the information content returned by the external services is different, that is, the second response information is different, so that the service scenario information is obtained by analyzing the second response information, and the service scenario information is classified and stored according to the service scenario information in the second response information, so that corresponding candidate files can be obtained, wherein each candidate file corresponds to one type of second response information.
Fig. 6 is a schematic diagram of a process of generating an alternative file according to an embodiment of the present application, and as shown in fig. 6, the external services associated with the target micro service include an external service a, an external service B, and an external service C. In a real service scene, a target micro service respectively sends a communication request a, a communication request B and a communication request C to each external service, after the external service A, the external service B and the external service C receive the corresponding communication requests, response information Respond _ a, response information Respond _ B and response information Respond _ C are respectively returned to the target micro service, and then a terminal device deployed with the target micro service obtains the response information Respond _ a, response information Respond _ B and response information Respond _ C through a baffle service, analyzes the obtained response information Respond _ a, response information Respond _ B and response information Respond _ C to obtain service scene information represented by each response information, and respectively generates a corresponding alternative file _ a, alternative file _ B and alternative file _ C.
Referring to the schematic process diagram of generating the candidate file shown in fig. 6, the process may be implemented by the barrier service, that is, the barrier service receives and analyzes the second response information returned by the external service, obtains the service scenario information corresponding to the second response information, and stores the service scenario information corresponding to the second response information as the corresponding candidate file based on the service scenario information corresponding to the second response information. The candidate files generated in the process have a specific mapping relationship with the communication request, for example, the communication request a corresponds to the candidate file _ a, and the communication request b corresponds to the candidate file _ b, and the mapping relationship is determined by analyzing and classifying the service scene information in the second response information. The second response information is classified by analyzing the service scene information in the second response information, so that the mapping relation between the communication request and the alternative file is obtained, the corresponding alternative file is formed, and the localization of the response information sent by each external service corresponding to the target micro service is realized.
Step S204, receiving a communication request sent by the target micro service, wherein the communication request is used for calling an external service.
Step S205, the communication request is analyzed to obtain a service identifier, and the service identifier represents the target banking service.
Step S206, according to the service identification, determining service scene information, wherein the service scene information represents a target service process corresponding to the target banking service.
Step S207, determining a target file from the multiple candidate files based on the service context information, where the target file is used to carry first response information returned by the external service corresponding to the target service process.
Illustratively, when the target microservice sends a communication request to the external service, the communication request includes an identification code for characterizing the external service, i.e. a service identifier. The service identification characterizes the target banking service, such as user login, transfer transaction, etc. Furthermore, different banking businesses represented by the business identifier correspond to different target business processes. It should be noted that, in a specific scenario, the same target banking service may correspond to different target service flows, that is, service scenario information, for example, banking services that a user logs in, and a mobile terminal APP logs in and a PC terminal browser logs in, where the related specific service flows are different, and first response information corresponding to different service flows is also different. Therefore, in this embodiment, after the service identifier is obtained, the corresponding service context information is determined according to the mapping relationship between the service identifier and the service context information. For example, the service identifier 01 corresponds to a mobile phone user login; the service identifier 02 corresponds to the PC user login. The service context information may also be characterized by a specific context identifier. Then, based on the specific service scenario information and the preset mapping relationship (see step S203 for details), the corresponding candidate file is obtained, and the candidate file is determined as the target file, where the target file carries the first response information returned by the external service corresponding to the target service process.
In a possible implementation manner, the service identifier includes a service node identifier, and the service node identifier represents a service node in the corresponding service flow, as shown in fig. 7, the specific implementation step of step S207 includes:
step S2071, determining a corresponding target service node according to the service node identifier.
Step S2072, determining a corresponding target file according to the target service node, where the target file is used to carry a first response message returned by the external service corresponding to the target service node.
Illustratively, the service identifier includes a service node identifier, and the service node identifier represents a service node in the service flow, for example, the service flow is a user login, in the service flow, the service flow includes several steps of user name validity judgment, password validity judgment, verification code judgment, user name password verification, user login state change, and the like, and each step corresponds to a service node, that is, the service node can be realized by different external services, so that the structural coupling of the micro-service system is looser. In the embodiment, the corresponding target file is determined through the service node identifier, so that the refinement of the external service is realized, and the more refined function test of the target micro service can be realized. In a possible implementation manner, the service identifier includes a service flow identifier and a service node identifier, and secondary retrieval is performed according to the service flow identifier and the service node identifier, so that a target file can be more flexibly and accurately positioned, response information for the service node or the service flow is obtained according to different target files (a target file obtained based on the service flow identifier and a target file obtained based on the service node identifier), different dimensionality tests and debugging of a target micro-service are realized, and the test and debugging efficiency and effect of the target micro-service are improved.
And S208, obtaining a target message according to the target file, and sending the target message to the target micro service, wherein the target message contains first response information and is used for responding to a communication request sent by the target micro service.
Optionally, in an embodiment of the present application, the method further includes:
step S209, acquiring the calling frequency corresponding to different external services within the first time period.
And step S210, deleting the alternative files corresponding to the external services with the calling frequency less than the frequency threshold according to the calling frequency corresponding to each external service.
Illustratively, after step S203, the terminal device records and stores the alternative files corresponding to the response information of different external services through the barrier service, and after a certain time, the number of the alternative files may increase with the passage of time, and the disk space is occupied. In this embodiment, the calling frequency (i.e., frequency or number) of different external services is periodically (first duration) screened, and the candidate file corresponding to the external service with the lower calling frequency is deleted, for example, the candidate file with the calling test of 0 is deleted, so that disk occupancy is reduced.
Steps S209 and S210 are executed based on an independent process to realize periodic cleaning of the candidate file, and if the candidate file is preset in the terminal device, the periodic cleaning may occur at any position in the steps in the above embodiments, for example, before step S201, or after step S208, or at any time node between S201 and S208; if the candidate file is not preset in the terminal device, steps S209 and S210 occur after step S203, which is not described herein again.
In this embodiment, the implementation manners of step S204 and step S208 are the same as the implementation manners of step S101 and step S103 in the embodiment shown in fig. 2 of this application, and are not described again.
Fig. 8 is a schematic structural diagram of a communication device based on a micro service architecture according to an embodiment of the present application, and as shown in fig. 8, a communication device 3 based on a micro service architecture according to the present embodiment includes:
a receiving module 31, configured to receive a communication request sent by a target micro service, where the communication request is used to invoke an external service;
the processing module 32 is configured to determine a corresponding target file according to the communication request, and obtain a target packet according to the target file, where the target file is stored locally and is used to carry first response information returned by the external service;
and the sending module 33 is configured to send the target packet to the target micro service, where the target packet includes the first response information, and the target packet is used to respond to the communication request sent by the target micro service.
In a possible implementation manner, when determining the corresponding target file according to the communication request, the processing module 32 is specifically configured to: analyzing the communication request to obtain a service identifier, wherein the service identifier represents the target banking service; and determining a corresponding target file according to the service identifier.
In a possible implementation manner, when determining the corresponding target file according to the service identifier, the processing module 32 is specifically configured to: determining service scene information according to the service identification, wherein the service scene information represents a target service flow corresponding to the target banking service; and determining a target file based on the service scene information, wherein the target file is used for bearing first response information returned by the external service corresponding to the target service process.
In a possible implementation manner, the service identifier includes a service node identifier, and the service node identifier represents one service node in the corresponding service flow; when determining the target file based on the service context information, the processing module 32 is specifically configured to: determining a corresponding target service node according to the service node identifier; and determining a corresponding target file according to the target service node, wherein the target file is used for bearing first response information returned by the external service corresponding to the target service node.
In a possible implementation manner, the receiving module 31 is specifically configured to: running baffle service corresponding to the target micro service, wherein the baffle service is a project object model dependency of the target micro service; and receiving the communication request sent by the target micro service through the baffle service.
In a possible implementation manner, before receiving the communication request sent by the target micro-service, the processing module 32 is further configured to: acquiring second response information returned by the external service; analyzing the second response information to obtain service scene information corresponding to the second response information, wherein the service scene information represents a target service process corresponding to the banking service; and classifying and storing the second response information according to the service scene information to generate an alternative file corresponding to the target service process, wherein the alternative file is used for bearing the second response information corresponding to the target service process.
In a possible implementation manner, after generating the candidate file corresponding to the target business process, the processing module 31 is further configured to: acquiring calling frequencies corresponding to different external services within a first time period; and deleting the alternative files corresponding to the external services with the calling frequency less than the frequency threshold according to the calling frequency corresponding to each external service.
Wherein, the receiving module 31, the processing module 32 and the sending module 33 are connected in sequence. The communication apparatus 3 based on the micro service system provided in this embodiment may execute the technical solution of the method embodiment shown in any one of fig. 2 to 7, and the implementation principle and the technical effect are similar, and are not described herein again.
Fig. 9 is a schematic view of an electronic device according to an embodiment of the present application, and as shown in fig. 9, an electronic device 4 according to the embodiment includes: a processor 41, and a memory 42 communicatively coupled to the processor 41.
Wherein the memory 42 stores computer-executable instructions;
the processor 41 executes the computer-executable instructions stored in the memory 42 to implement the communication method based on the micro service architecture provided in any embodiment corresponding to fig. 2-7 of the present application.
The memory 42 and the processor 41 are connected by a bus 43.
The relevant descriptions and effects corresponding to the steps in the embodiments corresponding to fig. 2 to fig. 7 can be understood, and are not described in detail herein.
One embodiment of the present application provides a computer-readable storage medium, on which a computer program is stored, where the computer program is executed by a processor to implement the communication method based on the micro service architecture provided in any embodiment of the present application corresponding to fig. 2 to fig. 7.
The computer readable storage medium may be, among others, ROM, Random Access Memory (RAM), CD-ROM, magnetic tape, floppy disk, optical data storage device, and the like.
An embodiment of the present application provides a computer program product, which includes a computer program, and when the computer program is executed by a processor, the computer program implements the communication method based on the micro service architecture provided in any embodiment of the present application corresponding to fig. 2 to fig. 7.
Fig. 10 is a block diagram of a terminal device 800, which may be a mobile phone, a computer, a digital broadcast terminal, a messaging device, a game console, a tablet device, a medical device, a fitness device, a personal digital assistant, etc., according to an exemplary embodiment of the present application.
Terminal device 800 may include one or more of the following components: a processing component 802, a memory 804, a power component 806, a multimedia component 808, an audio component 810, an input/output (I/O) interface 812, a sensor component 814, and a communication component 816.
The processing component 802 generally controls overall operation of the terminal device 800, such as operations associated with display, telephone calls, data communications, camera operations, and recording operations. The processing components 802 may include one or more processors 820 to execute instructions to perform all or a portion of the steps of the methods described above. Further, the processing component 802 can include one or more modules that facilitate interaction between the processing component 802 and other components. For example, the processing component 802 can include a multimedia module to facilitate interaction between the multimedia component 808 and the processing component 802.
The memory 804 is configured to store various types of data to support operations at the terminal device 800. Examples of such data include instructions for any application or method operating on terminal device 800, contact data, phonebook data, messages, pictures, videos, and so forth. The memory 804 may be implemented by any type or combination of volatile or non-volatile memory devices such as Static Random Access Memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic or optical disks.
Power components 806 provide power to the various components of terminal device 800. Power components 806 may include a power management system, one or more power sources, and other components associated with generating, managing, and distributing power for terminal device 800.
The multimedia component 808 includes a screen providing an output interface between the terminal device 800 and the user. In some embodiments, the screen may include a Liquid Crystal Display (LCD) and a Touch Panel (TP). If the screen includes a touch panel, the screen may be implemented as a touch screen to receive an input signal from a user. The touch panel includes one or more touch sensors to sense touch, slide, and gestures on the touch panel. The touch sensor may not only sense the boundary of a touch or slide action, but also detect the duration and pressure associated with the touch or slide operation. In some embodiments, the multimedia component 808 includes a front facing camera and/or a rear facing camera. When the terminal device 800 is in an operation mode, such as a shooting mode or a video mode, the front camera and/or the rear camera may receive external multimedia data. Each front camera and rear camera may be a fixed optical lens system or have a focal length and optical zoom capability.
The audio component 810 is configured to output and/or input audio signals. For example, the audio component 810 includes a Microphone (MIC) configured to receive an external audio signal when the terminal device 800 is in an operation mode, such as a call mode, a recording mode, and a voice recognition mode. The received audio signals may further be stored in the memory 804 or transmitted via the communication component 816. In some embodiments, audio component 810 also includes a speaker for outputting audio signals.
The I/O interface 812 provides an interface between the processing component 802 and peripheral interface modules, which may be keyboards, click wheels, buttons, etc. These buttons may include, but are not limited to: a home button, a volume button, a start button, and a lock button.
Sensor component 814 includes one or more sensors for providing various aspects of state assessment for terminal device 800. For example, sensor assembly 814 can detect an open/closed state of terminal device 800, the relative positioning of components, such as a display and keypad of terminal device 800, sensor assembly 814 can also detect a change in position of terminal device 800 or a component of terminal device 800, the presence or absence of user contact with terminal device 800, orientation or acceleration/deceleration of terminal device 800, and a change in temperature of terminal device 800. Sensor assembly 814 may include a proximity sensor configured to detect the presence of a nearby object without any physical contact. The sensor assembly 814 may also include a light sensor, such as a CMOS or CCD image sensor, for use in imaging applications. In some embodiments, the sensor assembly 814 may also include an acceleration sensor, a gyroscope sensor, a magnetic sensor, a pressure sensor, or a temperature sensor.
Communication component 816 is configured to facilitate communications between terminal device 800 and other devices in a wired or wireless manner. The terminal device 800 may access a wireless network based on a communication standard, such as WiFi, 3G, 4G, 5G, or other standard communication networks, or a combination thereof. In an exemplary embodiment, the communication component 816 receives a broadcast signal or broadcast related information from an external broadcast management system via a broadcast channel. In an exemplary embodiment, communications component 816 further includes a Near Field Communications (NFC) module to facilitate short-range communications. For example, the NFC module may be implemented based on Radio Frequency Identification (RFID) technology, infrared data association (IrDA) technology, Ultra Wideband (UWB) technology, Bluetooth (BT) technology, and other technologies.
In an exemplary embodiment, the terminal device 800 may be implemented by one or more Application Specific Integrated Circuits (ASICs), Digital Signal Processors (DSPs), Digital Signal Processing Devices (DSPDs), Programmable Logic Devices (PLDs), Field Programmable Gate Arrays (FPGAs), controllers, micro-controllers, microprocessors or other electronic components for performing the methods provided by any of the embodiments of fig. 2-7 of the present application.
In an exemplary embodiment, a non-transitory computer-readable storage medium comprising instructions, such as the memory 804 comprising instructions, executable by the processor 820 of the terminal device 800 to perform the above-described method is also provided. For example, the non-transitory computer readable storage medium may be a ROM, a Random Access Memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, an optical data storage device, and the like.
An embodiment of the present application further provides a non-transitory computer-readable storage medium, where instructions in the storage medium, when executed by a processor of a terminal device, enable the terminal device 800 to perform the method provided in any one of the embodiments corresponding to fig. 2 to fig. 7 of the present application.
In the several embodiments provided in the present application, it should be understood that the disclosed apparatus and method may be implemented in other ways. For example, the above-described apparatus embodiments are merely illustrative, and for example, a division of modules is merely a division of logical functions, and an actual implementation may have another division, for example, a plurality of modules or components may be combined or integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection through some interfaces, devices or modules, and may be in an electrical, mechanical or other form.
Other embodiments of the present application will be apparent to those skilled in the art from consideration of the specification and practice of the application disclosed herein. This application is intended to cover any variations, uses, or adaptations of the invention following, in general, the principles of the application and including such departures from the present disclosure as come within known or customary practice within the art to which the invention pertains. It is intended that the specification and examples be considered as exemplary only, with a true scope and spirit of the application being indicated by the following claims.
It will be understood that the present application is not limited to the precise arrangements described above and shown in the drawings and that various modifications and changes may be made without departing from the scope thereof. The scope of the application is limited only by the appended claims.

Claims (10)

1. A communication method based on a micro service system is characterized by comprising the following steps:
receiving a communication request sent by a target micro service, wherein the communication request is used for calling an external service;
determining a corresponding target file according to the communication request, wherein the target file is stored locally and is used for bearing first response information returned by the external service;
and obtaining a target message according to the target file, and sending the target message to the target micro service, wherein the target message comprises the first response information, and the target message is used for responding to a communication request sent by the target micro service.
2. The method of claim 1, wherein determining the corresponding target file according to the communication request comprises:
analyzing the communication request to obtain a service identifier, wherein the service identifier represents the target banking service;
and determining a corresponding target file according to the service identifier.
3. The method of claim 2, wherein determining the corresponding target file according to the service identifier comprises:
determining service scene information according to the service identification, wherein the service scene information represents a target service process corresponding to the target banking service;
and determining the target file based on the service scene information, wherein the target file is used for bearing first response information returned by the external service corresponding to the target service process.
4. The method of claim 3, wherein the service identifier comprises a service node identifier, and wherein the service node identifier represents a service node in a corresponding service flow; determining the target file based on the service scenario information, including:
determining a corresponding target service node according to the service node identifier;
and determining a corresponding target file according to the target service node, wherein the target file is used for bearing first response information returned by the external service corresponding to the target service node.
5. The method of claim 1, wherein receiving a communication request sent by a target microservice comprises:
running a baffle service corresponding to the target micro service, wherein the baffle service is a project object model dependency of the target micro service;
receiving, by the barrier service, the communication request sent by the target microservice.
6. The method of any of claims 1-5, wherein prior to receiving the communication request sent by the target microservice, the method further comprises:
acquiring second response information returned by the external service;
analyzing the second response information to obtain service scene information corresponding to the second response information, wherein the service scene information represents a target service process corresponding to banking services;
and classifying and storing the second response information according to the service scene information to generate an alternative file corresponding to a target service process, wherein the alternative file is used for bearing the second response information corresponding to the target service process.
7. The method of claim 6, wherein after generating the candidate file corresponding to the target business process, the method further comprises:
acquiring calling frequencies corresponding to different external services within a first time period;
and deleting the alternative files corresponding to the external services with the calling frequency less than the frequency threshold according to the calling frequency corresponding to each external service.
8. A communication device based on a microservice architecture, comprising:
the receiving module is used for receiving a communication request sent by a target micro-service, and the communication request is used for calling an external service;
the processing module is used for determining a corresponding target file according to the communication request and obtaining a target message according to the target file, wherein the target file is stored locally and is used for bearing first response information returned by the external service;
and the sending module is used for sending the target message to the target micro service, wherein the target message comprises the first response information, and the target message is used for responding to a communication request sent by the target micro service.
9. An electronic device, comprising: a processor, and a memory communicatively coupled to the processor;
the memory stores computer-executable instructions;
the processor executes computer-executable instructions stored by the memory to implement the microservices-based communication method of any one of claims 1 to 7.
10. A computer-readable storage medium having stored thereon computer-executable instructions for implementing the microservice-based communication method of any of claims 1-7 when executed by a processor.
CN202210080747.7A 2022-01-24 2022-01-24 Communication method, device, equipment and storage medium based on micro service system Pending CN114428737A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210080747.7A CN114428737A (en) 2022-01-24 2022-01-24 Communication method, device, equipment and storage medium based on micro service system

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210080747.7A CN114428737A (en) 2022-01-24 2022-01-24 Communication method, device, equipment and storage medium based on micro service system

Publications (1)

Publication Number Publication Date
CN114428737A true CN114428737A (en) 2022-05-03

Family

ID=81313546

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210080747.7A Pending CN114428737A (en) 2022-01-24 2022-01-24 Communication method, device, equipment and storage medium based on micro service system

Country Status (1)

Country Link
CN (1) CN114428737A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115633073A (en) * 2022-09-02 2023-01-20 易保网络技术(上海)有限公司 Micro-service calling method, electronic device, system and readable storage medium

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115633073A (en) * 2022-09-02 2023-01-20 易保网络技术(上海)有限公司 Micro-service calling method, electronic device, system and readable storage medium
CN115633073B (en) * 2022-09-02 2023-11-14 易保网络技术(上海)有限公司 Micro-service calling method, electronic device, system and readable storage medium

Similar Documents

Publication Publication Date Title
CN106126685B (en) Page loading method and device
CN111274131A (en) Interface testing method and device, electronic equipment and storage medium
CN106598677A (en) Installation package downloading method and device
CN115185717B (en) Interface calling method and device, electronic equipment and storage medium
CN112256563B (en) Android application stability testing method and device, electronic equipment and storage medium
CN109391734A (en) Data transmission method for uplink, device, terminal and storage medium
CN110704030A (en) Interface configuration information generation method and device, electronic equipment and storage medium
CN107562500B (en) Debugging device, method and equipment
CN114422472A (en) Network address conversion method and device and electronic equipment
CN114217803A (en) Page function problem processing method and device and electronic equipment
CN114428737A (en) Communication method, device, equipment and storage medium based on micro service system
CN111079040B (en) Resource sniffing method, device, terminal, server and storage medium
CN109213580A (en) Using exchange method and device
CN110213062B (en) Method and device for processing message
CN115373763B (en) Plug-in loading method and device, electronic equipment and storage medium
CN114896165A (en) Testing method and device of conversation robot system, electronic equipment and storage medium
CN110457192A (en) A kind of file monitor method and device, terminal, storage medium
CN113420205B (en) Method and device for determining shared source account, terminal equipment and server
CN115509872A (en) Client behavior data acquisition method and device
CN109947640B (en) Regression test-based core function coverage statistical method and device
CN114780334A (en) Power consumption monitoring method, power consumption monitoring device and storage medium
CN106155863A (en) Terminal anticipatory behavior control method and terminal
CN112860625A (en) Data acquisition method, data storage method, device, equipment and storage medium
CN107391128B (en) Method and device for monitoring virtual file object model vdom
CN109086143B (en) Application interaction method and device

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