[go: nahoru, domu]

CN113760466A - Multi-transaction processing method, device, computer system and readable storage medium - Google Patents

Multi-transaction processing method, device, computer system and readable storage medium Download PDF

Info

Publication number
CN113760466A
CN113760466A CN202011289716.XA CN202011289716A CN113760466A CN 113760466 A CN113760466 A CN 113760466A CN 202011289716 A CN202011289716 A CN 202011289716A CN 113760466 A CN113760466 A CN 113760466A
Authority
CN
China
Prior art keywords
transaction
output
annotation
custom
executing
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
CN202011289716.XA
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.)
Beijing Jingdong Century Trading Co Ltd
Beijing Wodong Tianjun Information Technology Co Ltd
Original Assignee
Beijing Jingdong Century Trading Co Ltd
Beijing Wodong Tianjun Information Technology Co Ltd
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 Beijing Jingdong Century Trading Co Ltd, Beijing Wodong Tianjun Information Technology Co Ltd filed Critical Beijing Jingdong Century Trading Co Ltd
Priority to CN202011289716.XA priority Critical patent/CN113760466A/en
Publication of CN113760466A publication Critical patent/CN113760466A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • 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/466Transaction processing
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/70Software maintenance or management
    • G06F8/71Version control; Configuration management
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/70Software maintenance or management
    • G06F8/73Program documentation

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Computer Security & Cryptography (AREA)
  • Library & Information Science (AREA)
  • Stored Programmes (AREA)

Abstract

The present disclosure provides a multi-transaction processing method, a multi-transaction processing apparatus, a computer system, and a computer-readable storage medium. The multi-transaction processing method comprises the following steps of: obtaining a self-defined annotation configured in a first transaction; executing a method corresponding to the user-defined annotation to obtain the output of the first transaction; and taking the output of the first transaction as the input of a second transaction, and executing the second transaction to realize multi-transaction processing.

Description

Multi-transaction processing method, device, computer system and readable storage medium
Technical Field
The present disclosure relates to the field of computer technologies, and in particular, to a multi-transaction processing method, a multi-transaction processing apparatus, a computer system, and a computer-readable storage medium.
Background
In the computer field, "transaction" is used generically to refer to a unit of program execution. A complete project usually includes multiple program execution units with logical association, i.e. includes multiple transactions cooperating with each other. Therefore, a project needs to be implemented by combining all the matters in the development phase, the test phase and the actual application phase to play the normal function.
In implementing the disclosed concept, the inventors found that there are at least the following problems in the related art: the too strong data dependency relationship exists among a plurality of affairs of a project, so that under the condition that one affair cannot normally output a result, other affairs related to the affair can be influenced, and the whole research and development of the project are not facilitated.
Disclosure of Invention
In view of the above, the present disclosure provides a multi-transaction processing method, a multi-transaction processing apparatus, a computer system, and a computer-readable storage medium.
One aspect of the present disclosure provides a multi-transaction processing method, wherein the multi-transaction includes at least a first transaction and a second transaction, an output of the first transaction being an input of the second transaction, the method including: obtaining a self-defined annotation configured in the first transaction; executing a method corresponding to the user-defined annotation to obtain the output of the first transaction; and taking the output of the first transaction as the input of the second transaction, and executing the second transaction to realize the multi-transaction processing.
Another aspect of the present disclosure provides a multi-transaction processing apparatus, wherein the multi-transaction includes at least a first transaction and a second transaction, an output of the first transaction being an input of the second transaction, the apparatus including: the first acquisition module is used for acquiring the self-defined annotation configured in the first transaction; the first execution module is used for executing the method corresponding to the user-defined annotation to obtain the output of the first transaction; and the processing module is used for taking the output of the first transaction as the input of the second transaction and executing the second transaction so as to realize the multi-transaction processing.
Another aspect of the present disclosure provides a computer system comprising: one or more processors; memory for storing one or more programs, wherein the one or more programs, when executed by the one or more processors, cause the one or more processors to implement the method as described above.
Another aspect of the present disclosure provides a computer-readable storage medium having stored thereon computer-executable instructions for implementing the method as described above when executed.
Another aspect of the disclosure provides a computer program comprising computer executable instructions for implementing the method as described above when executed.
According to the embodiment of the disclosure, the user-defined annotation configured in the first transaction is obtained; executing a method corresponding to the user-defined annotation to obtain the output of the first transaction; the output of the first transaction can be determined according to a method corresponding to the self-defined annotation configured in the first transaction, so that the technical problem that abnormal execution of one transaction can affect other transactions due to the fact that the dependence relationship of data among different transactions is too strong is at least partially overcome, and the technical effect of decoupling the strong dependence of data among multiple transactions is achieved.
Drawings
The above and other objects, features and advantages of the present disclosure will become more apparent from the following description of embodiments of the present disclosure with reference to the accompanying drawings, in which:
FIG. 1 schematically illustrates an exemplary system architecture to which a multi-transaction processing method may be applied, according to an embodiment of the disclosure;
FIG. 2 schematically illustrates a flow chart of a multiple transaction processing method according to an embodiment of the present disclosure;
FIG. 3 schematically illustrates a process flow diagram for a target method configured with custom annotations according to an embodiment of the disclosure;
FIG. 4 schematically illustrates a schematic diagram of a multi-transaction processing method according to an embodiment of the present disclosure;
FIG. 5 schematically shows a block diagram of a multi-transaction processing apparatus according to an embodiment of the present disclosure; and
FIG. 6 schematically illustrates a block diagram of a computer system suitable for implementing the multi-transaction processing method described above, in accordance with an embodiment of the present disclosure.
Detailed Description
Hereinafter, embodiments of the present disclosure will be described with reference to the accompanying drawings. It should be understood that the description is illustrative only and is not intended to limit the scope of the present disclosure. In the following detailed description, for purposes of explanation, numerous specific details are set forth in order to provide a thorough understanding of the embodiments of the disclosure. It may be evident, however, that one or more embodiments may be practiced without these specific details. Moreover, in the following description, descriptions of well-known structures and techniques are omitted so as to not unnecessarily obscure the concepts of the present disclosure.
The terminology used herein is for the purpose of describing particular embodiments only and is not intended to be limiting of the disclosure. The terms "comprises," "comprising," and the like, as used herein, specify the presence of stated features, steps, operations, and/or components, but do not preclude the presence or addition of one or more other features, steps, operations, or components.
All terms (including technical and scientific terms) used herein have the same meaning as commonly understood by one of ordinary skill in the art unless otherwise defined. It is noted that the terms used herein should be interpreted as having a meaning that is consistent with the context of this specification and should not be interpreted in an idealized or overly formal sense.
Where a convention analogous to "at least one of A, B and C, etc." is used, in general such a construction is intended in the sense one having skill in the art would understand the convention (e.g., "a system having at least one of A, B and C" would include but not be limited to systems that have a alone, B alone, C alone, a and B together, a and C together, B and C together, and/or A, B, C together, etc.). Where a convention analogous to "A, B or at least one of C, etc." is used, in general such a construction is intended in the sense one having skill in the art would understand the convention (e.g., "a system having at least one of A, B or C" would include but not be limited to systems that have a alone, B alone, C alone, a and B together, a and C together, B and C together, and/or A, B, C together, etc.).
Unit testing (single testing for short), front-end development and the like belong to a concrete expression form of multi-transaction processing.
Taking the front-end development as an example, the front-end and the back-end can be understood as two different transactions having an association relationship with each other. The inventor finds that in the process of implementing the disclosed concept, strong data dependence exists between the front end and the back end in the process of independent development of the front end and the back end.
Taking the unit test as an example, a Mockito technique is proposed in the unit test, which is a simulation framework for the unit test in Java, designed to be easy to use when the test requires simulation, simulate parameter objects, verify execution results, and the like. For example, the parameter objects of the simulation construction can be annotated by using @ mock, @ spy and the like, the import reference and the return value can be simulated and realized by methods such as while (), the network return (), and the execution result can be verified by means of mockito. However, the inventor finds that in the process of implementing the concept of the present disclosure, a single test execution process needs a single hard coding mode, and a large amount of codes and code packets which are irrelevant to the single test execution process need to be created for the single test; a single-test code invades a business/technical process, and an @ mock simulation parameter object is required to be used independently no matter an external dependent parameter or an internal dependent parameter; furthermore, during unit testing, simulated return values need to be created and returned at single test execution, heavily coupled with the execution process.
Embodiments of the present disclosure provide a multi-transaction processing method, a multi-transaction processing apparatus, a computer system, and a computer-readable storage medium. The multi-transaction processing method comprises the following steps of: obtaining a self-defined annotation configured in a first transaction; executing a method corresponding to the user-defined annotation to obtain the output of the first transaction; and taking the output of the first transaction as the input of a second transaction, and executing the second transaction to realize multi-transaction processing.
Fig. 1 schematically illustrates an exemplary system architecture 100 to which the multi-transaction processing method may be applied, according to an embodiment of the present disclosure. It should be noted that fig. 1 is only an example of a system architecture to which the embodiments of the present disclosure may be applied to help those skilled in the art understand the technical content of the present disclosure, and does not mean that the embodiments of the present disclosure may not be applied to other devices, systems, environments or scenarios.
As shown in fig. 1, the system architecture 100 according to this embodiment may include terminal devices 101, 102, 103, a network 104 and a server 105. The network 104 serves as a medium for providing communication links between the terminal devices 101, 102, 103 and the server 105. Network 104 may include various connection types, such as wired and/or wireless communication links, and so forth.
The user may use the terminal devices 101, 102, 103 to interact with the server 105 via the network 104 to receive or send messages or the like. The terminal devices 101, 102, 103 may have various communication client applications installed thereon, such as a shopping application, a web browser application, a search application, an instant messaging tool, a mailbox client, and/or social platform software.
The terminal devices 101, 102, 103 may be various electronic devices having a display screen and supporting web browsing, including but not limited to smart phones, tablet computers, laptop portable computers, desktop computers, and the like.
The server 105 may be a server that provides various services, such as a background management server that provides support for websites browsed by users using the terminal devices 101, 102, 103. The background management server may analyze and perform other processing on the received data such as the user request, and feed back a processing result (e.g., a webpage, information, or data obtained or generated according to the user request) to the terminal device.
It should be noted that the multi-transaction processing method provided by the embodiment of the present disclosure may be generally executed by the server 105. Accordingly, the multi-transaction processing apparatus provided by the embodiment of the present disclosure may be generally disposed in the server 105. The multi-transaction processing method provided by the embodiment of the present disclosure may also be executed by a server or a server cluster different from the server 105 and capable of communicating with the terminal devices 101, 102, 103 and/or the server 105. Accordingly, the multi-transaction processing apparatus provided by the embodiment of the present disclosure may also be disposed in a server or a server cluster different from the server 105 and capable of communicating with the terminal devices 101, 102, 103 and/or the server 105. Alternatively, the multi-transaction processing method provided by the embodiment of the present disclosure may also be executed by the terminal device 101, 102, or 103, or may also be executed by another terminal device different from the terminal device 101, 102, or 103. Accordingly, the multi-transaction processing apparatus provided by the embodiment of the present disclosure may also be disposed in the terminal device 101, 102, or 103, or disposed in another terminal device different from the terminal device 101, 102, or 103.
For example, the transaction configured with the custom annotation may be originally stored in any of the terminal devices 101, 102, or 103 (e.g., but not limited to terminal device 101), or stored on an external storage device and may be imported into terminal device 101. Then, the terminal device 101 may locally execute the multi-transaction processing method provided by the embodiment of the present disclosure, or send the transaction configured with the custom annotation to another terminal device, server, or server cluster, and execute the multi-transaction processing method provided by the embodiment of the present disclosure by another terminal device, server, or server cluster that receives the transaction configured with the custom annotation.
It should be understood that the number of terminal devices, networks, and servers in fig. 1 is merely illustrative. There may be any number of terminal devices, networks, and servers, as desired for implementation.
FIG. 2 schematically shows a flow chart of a multi-transaction processing method according to an embodiment of the disclosure.
According to an embodiment of the present disclosure, the multiple transactions may include at least a first transaction and a second transaction, for example, and an output of the first transaction is an input of the second transaction, for example.
Based on this, referring to fig. 2, the multi-transaction processing method described above includes operations S201 to S203.
In operation S201, a custom annotation configured in a first transaction is obtained.
According to the embodiment of the disclosure, the custom annotation can be, for example, a custom framework which is located on the mock method level and is developed and designed by a programmer, and can realize some specific functions, for example, the specific functions can be designed for an actual transaction and can realize the same or similar functions with the transaction, and the original parameters of the framework system can be normally used without a separate mock parameter.
In operation S202, a method corresponding to the custom annotation is executed, and an output of the first transaction is obtained.
According to the embodiment of the disclosure, the method corresponding to the custom annotation includes the related program capable of implementing the above function, and the program execution result is obtained by executing the related program, so that as the output result of the first transaction, for example, when the first transaction cannot normally output the result, the method corresponding to the custom annotation is executed to provide a simulation result for the first transaction to output.
It should be noted that the output result of the above-mentioned related program may be set to be consistent or inconsistent with the data type of the output result of the corresponding transaction in the case of normal execution, and is not limited herein.
In operation S203, the second transaction is executed with the output of the first transaction as the input of the second transaction to implement multi-transaction processing.
According to the embodiment of the present disclosure, after the output of the first transaction is obtained in operation S202, the input condition may be provided for the second transaction, so that both the inter-dependent transactions can be executed normally.
By the embodiment of the disclosure, since the user-defined annotation is added in the first transaction, normal output of the first transaction can be realized or analog output is provided for the first transaction by executing the method corresponding to the user-defined annotation, and the problem of strong data dependence among different transactions can be effectively solved. Particularly, under the condition that the first transaction cannot be normally executed, for example, in the process of independently developing the front end and the back end in the initial stage of a project, the front end (or the back end) is not developed yet, but the back end (or the front end) needs to rely on the data of the front end to carry out corresponding design or test.
According to an embodiment of the present disclosure, the multi-transaction processing method further includes: before the operation S202, obtaining configuration parameters for characterizing whether the custom annotation is enabled; under the condition that the value of the configuration parameter is the first enumeration value, the user-defined annotation is forbidden; normally starting the self-defined annotation under the condition that the value of the configuration parameter is the second enumeration value; when the value of the configuration parameter is a third enumeration value, the user-defined annotation is enabled forcibly; and in the case that the custom annotation is enabled normally or forcibly enabled, the above operation S202 is performed again.
The multi-transaction processing method is further described with reference to fig. 3 to 4 in conjunction with the following embodiments.
According to a specific embodiment of the present disclosure, first, based on an AOP (Aspect organized Programming) tangent plane principle, a method (a target method, which may refer to a specific transaction of multiple transactions, for example, the first transaction) that requires mock data (i.e., adding a custom annotation) is captured (the target method may refer to a specific transaction of multiple transactions), a custom annotation is added in a program flow corresponding to the method, and a configuration file for the custom annotation is set under a target application item corresponding to the method, so as to determine whether to execute the custom annotation and how to execute a method corresponding to the custom annotation according to the custom annotation and the configuration file.
According to the embodiment of the disclosure, the above-mentioned custom annotation may be named as KMock, the implementation language may be java, for example, a project implementing the KMock framework finally outputs a jar package and a maven (a project object model, a software project management tool that can manage the construction, report, and document of the project through a small piece of description information) dependent file containing development code files, and a user introduces the maven dependency to use an API (application program interface, here, the KMock framework) in the subsequent development process of the project.
In the early stage of construction of the target application item, the maven dependency of the KMock framework can be introduced, for example, by:
Figure BDA0002782059110000081
xml in the target application project, for example.
Then, a simple configuration file is configured, which mainly includes a configuration of value enumeration, for example, when the setting value is enumerated as 0 (i.e., the first enumerated value), KMock is not enabled, when the value is enumerated as 1 (i.e., the second enumerated value), KMock is normally enabled, and when the value is enumerated as 2 (i.e., the third enumerated value), KMock is forcibly enabled.
Configuration for value enumeration of KMock may be, for example, adding a blue j. mock parameter in a properties configuration file, in this embodiment, for example, setting a configuration file named application-dev. properties in a target application item, and then setting in the configuration file: mock 1, indicating that the KMock annotation may be normally enabled at this time.
With the above-described embodiments of the present disclosure, the target method is facilitated in a multi-environment application scenario by supporting whether the KMock function is enabled using properties or yml configuration files or global system parameter configuration.
After configuring the KMock framework environment of the target application item, the @ KMock annotation can be added to the target method of the target application item, so that when the target method is called, based on the AOP tangent plane principle, the surrounding method configured by the framework is executed first, and thus the method corresponding to the annotation can be executed. An around () method may also be set to check whether the KMock function is configured to be turned on or forced to be executed. In this embodiment, for example, an annotation statement is added to a target method dmpcontroller. @ KMock ("dealmockmockhandle"), where dealmocksandle defines a specific execution policy for the KMock that applies to the target method.
It should be noted that the KMock may define a multi-policy class, implement a doHandle () method of a kmockhandle (a packaged model for which a corresponding policy may be designed) interface, and include a plurality of custom policies in the multi-policy class, which is applied to the specific execution of the target method return simulation data. The class can be managed by a Spring Bean container, and whether the class is in an annotation configuration mode or an xml configuration mode, the Spring Bean container collects all objects of the implementation class of the KMockHanlde interface into parameters of a Map < name, KMockHanlde > type, wherein the Map is used for storing all defined KMock policies, the name is a policy name, and the KMockHanlde is policy content corresponding to the name. For the defined multi-element strategy in the Map, the parameters of the tangent plane can be assigned subsequently by means of injection.
According to the above embodiments of the present disclosure, the above multivariate policy class and the execution method of the above dealmockholder policy are defined, for example, in the delamocksolder.
Figure BDA0002782059110000091
FIG. 3 schematically illustrates a process flow diagram for a target method configured with custom annotations according to an embodiment of the disclosure.
As shown in fig. 3, there is a normal request for requesting to execute a business/system method (i.e. a target method), and in case that the @ KMock annotation is not configured in the program corresponding to the method, the target method is directly executed to obtain an output result, and the output result is used as a return value of the target method in response to the normal request; in case that the @ KMock annotation is configured in the program corresponding to the method, the method corresponding to the @ KMock is executed to obtain a return value of the target method in response to a normal request.
According to the embodiment shown in fig. 3, the method for performing @ KMock mapping includes, for example: the KMockBaseAspect executes and determines whether to execute the KMock function (e.g., including not enabling KMock, and executing and enforcing KMock) based on the enumerated value.
According to the embodiment shown in fig. 3, in the case that it is determined that the KMock function is not enabled according to the enumerated value, that is, in the case that it is determined that the aforementioned blue j.mock is 0 in this embodiment, the service/system method is directly executed to obtain an output result, and the output result is used as a return value of the target method in response to a normal request.
According to an embodiment of the present disclosure, in the case that the custom annotation is forcibly enabled, the operation S202 includes: acquiring a custom strategy corresponding to a first transaction; executing a custom strategy to obtain simulated service data; and outputting the simulated service data as an output of the first transaction.
Referring to fig. 3, in this embodiment, when it is determined that the blue j.mock is 2, the KMock is forcibly executed, the method-defined KMock policy is acquired, the user-defined KMock policy is executed, the KMock parameter is obtained, and a value of the KMock parameter is used as a return value of the target method in response to the normal request.
According to an embodiment of the present disclosure, in a case that the custom annotation is normally enabled, the operation S202 includes: executing the first transaction; and taking the normal output parameter as the output of the first transaction under the condition that the output parameter of the first transaction is normal.
According to an embodiment of the present disclosure, in the case that the custom annotation is normally enabled, the operation S202 further includes: executing the first transaction; acquiring a custom strategy corresponding to the first transaction under the condition that the output parameter of the first transaction is abnormal; executing a custom strategy to obtain simulated service data; and outputting the simulated service data as an output of the first transaction.
Referring to fig. 3, in this embodiment, when it is determined that the value of blue is 1, a KMock function is enabled, and a service method is executed. And under the condition that the business method is normal, taking the normal parameter value as a return value of the target method responding to the normal request; and under the condition that the business method is abnormal in participation (for example, the participation is null), triggering the KMock function, acquiring a method self-defined KMock strategy, executing the self-defined KMock strategy to obtain the KMock participation, and taking the KMock participation value as a return value of the target method responding to the normal request.
According to the above embodiments of the present disclosure, in the case where the value of blue j.mock is 1 and the parameter of the executed business method is empty, and in the case where the value of blue j.mock is 2, the KMock parameter obtained by executing the above target method is expressed as:
Figure BDA0002782059110000111
through the above embodiments of the present disclosure, since the KMock function may be triggered when the black is 1 and the parameter of the executed service method is empty, the mock function implemented by the KMock framework of the present disclosure may also be used to support default data returned after functions occurring in the transaction execution process, such as, for example, functions including anti-flush, downgrading, current limiting, and fusing.
According to an embodiment of the present disclosure, the acquiring the custom policy corresponding to the first transaction includes: acquiring a custom strategy set corresponding to multiple transactions; obtaining a custom policy name in a custom annotation configured in a first transaction; and acquiring a custom policy corresponding to the first transaction from the custom policy set according to the custom policy name.
Referring to fig. 3, the process executed by the KMockBaseAspect (i.e. the above-mentioned process of acquiring the custom policy corresponding to the first transaction) may be used to determine a specific execution policy when the KMock function needs to be executed subsequently, and this process may be expressed as:
Figure BDA0002782059110000112
Figure BDA0002782059110000121
in this embodiment, the above program is designed in a dmpmockaspect method of a target application, that is, a custom cut-plane class is created and inherits KMockBaseAspect, 2 parameters in a parent class are assigned, and @ Resource annotation and @ Value annotation are added to a set () method of the parameters by using Java parameter automatic injection and Spring parameter assignment, so that object values in a container can be automatically read, where a kmockMap parameter is the set object of the multi-policy automatically encapsulated by using the Spring container, an object of each policy is obtained by a policy name, and then a policy method is executed to return mock data. The specific execution method is in the KMock packaged method.
Through the embodiment of the disclosure, as the target method of declaring the custom annotation is captured by using the section, the @ KMock annotation can be added only on the method needing mock, and the coding flow of a large amount of codes irrelevant to the transaction itself in the single-side execution process is reduced. By taking the policy name indicated in the custom note, the policy object can be retrieved from the container and executed, and the method can be applied to various types of different transactions. And in the surrounding method of the section, reading the configuration parameter blue j.mock to realize three logic functions of not starting the mock function, normally starting the mock function and forcibly executing the mock, and the method can also be applied to various transaction application environments.
FIG. 4 schematically illustrates a schematic diagram of a multi-transaction processing method according to an embodiment of the present disclosure.
As shown in fig. 4, the request module corresponds to the normal request in fig. 3, the annotation triggers the AOP module to correspond to the process of configuring @ KMock in fig. 3, the execute module corresponds to the process of executing KMockBaseAspect in fig. 3, the multivariate policy KMock module corresponds to the process of executing the custom KMock policy in fig. 3, and the data structure module may correspond to the process of returning the KMock participation and response in fig. 3. The execution Aspect module depends on the parameter configuration module, sources of parameter configuration may include configuration files and system parameters, the configuration files may include the application-dev.properties file, for example, and the execution Aspect module also depends on an Aspect expansion module, which means that the KMockBaseAspect in the above embodiment may be expanded according to actual application requirements, and an expansion result may include, for example, an improvement in KMock function, an improvement in KMock configuration, an improvement in KMock execution process, and the like, which is not limited herein, and an expansion manner is, for example, based on SPI expansion.
The SPI is a dynamic loading mechanism implemented by a combination of "Interface-based programming + policy schema + configuration file", and is actually a combination of "SPI and policy schema". Because various abstract classes of system design often have a plurality of different implementation schemes, in object-oriented design, programming is generally recommended among modules based on interfaces, and hard coding is not performed on implementation classes among the modules. In order to implement the process of module assembly (which may be represented as plug-in and unplug), without affecting the original design code of the program, the foregoing embodiment of the present disclosure is implemented by using a Java SPI extension mechanism, which is used to find a service implementation mechanism for a certain interface.
By the embodiment of the disclosure, a multi-transaction processing method which can be oriented to different transactions and different environments is realized, the control right of assembly is moved out of a program through an SPI expanding mechanism, and inter-transaction decoupling can be effectively realized; by utilizing the AOP, all parts of the business logic can be isolated, so that the coupling degree between all parts of the business logic is reduced, the reusability of a program is improved, and the development efficiency is improved.
It should be noted that, a java agent (java agent) technology may also be used to dynamically generate a byte code file to replace the AOP section logic in the above embodiment. The difference is that when the java agent technology is used to implement the above scheme, an additional process needs to be separately started to execute the agent, for example, the process can be implemented by separately writing a program for loading the agent class.
FIG. 5 schematically shows a block diagram of a multi-transaction processing apparatus according to an embodiment of the disclosure.
As shown in fig. 5, the multi-transaction processing apparatus 500 includes a first obtaining module 510, a first executing module 520, and a processing module 530.
A first obtaining module 510, configured to obtain the custom annotation configured in the first transaction.
The first executing module 520 is configured to execute a method corresponding to the customized annotation, and obtain an output of the first transaction.
And the processing module 530 is configured to execute the second transaction by taking the output of the first transaction as the input of the second transaction, so as to implement multi-transaction processing.
According to an embodiment of the present disclosure, the multi-transaction processing apparatus further includes a second obtaining module, a disabling module, a first enabling module, a second enabling module, and a second executing module.
And the second acquisition module is used for acquiring the configuration parameters for representing whether the user-defined annotation is enabled or not before the method corresponding to the user-defined annotation is executed and the output of the first transaction is obtained.
And the disabling module is used for disabling the self-defined annotation under the condition that the value of the configuration parameter is the first enumeration value.
And the first enabling module is used for normally enabling the user-defined annotation under the condition that the value of the configuration parameter is the second enumerated value.
And the second enabling module is used for forcibly enabling the user-defined annotation under the condition that the value of the configuration parameter is the third enumeration value.
And the second execution module is used for executing the method corresponding to the self-defined annotation under the condition that the self-defined annotation is normally enabled or forcibly enabled to obtain the output of the first transaction.
According to an embodiment of the present disclosure, in a case where the second enabling module is enabled, the second executing module includes a first obtaining unit, a first executing unit, and a first defining unit.
The first obtaining unit is used for obtaining a custom strategy corresponding to the first transaction.
And the first execution unit is used for executing the custom strategy to obtain the simulated service data.
A first defining unit for outputting the emulated service data as an output of the first transaction.
According to an embodiment of the present disclosure, in a case that the first enabling module is enabled, the second executing module further includes a second executing unit and a second defining unit.
A second execution unit to execute the first transaction.
And the second definition unit is used for taking the normal output parameter as the output of the first transaction under the condition that the output parameter of the first transaction is normal.
According to an embodiment of the present disclosure, in a case that the first enabling module is enabled, the second executing module further includes a third executing unit, a second obtaining unit, a fourth executing unit, and a third defining unit.
And the third execution unit is used for executing the first transaction.
And the second acquisition unit is used for acquiring the custom strategy corresponding to the first transaction when the output parameter of the first transaction is abnormal.
And the fourth execution unit is used for executing the custom strategy to obtain the simulated service data.
A third defining unit for outputting the simulated service data as an output of the first transaction.
According to an embodiment of the present disclosure, the first obtaining unit or the second obtaining unit includes a first obtaining subunit, a second obtaining subunit, and a third obtaining subunit.
The first acquiring subunit is used for acquiring a custom policy set corresponding to multiple transactions.
And the second acquisition subunit is used for acquiring the custom policy name in the custom annotation configured in the first transaction.
And the third acquiring subunit is used for acquiring the custom strategy corresponding to the first transaction from the custom strategy set according to the custom strategy name.
Any of the modules, units, sub-units, or at least part of the functionality of any of them according to embodiments of the present disclosure may be implemented in one module. Any one or more of the modules, units and sub-units according to the embodiments of the present disclosure may be implemented by being split into a plurality of modules. Any one or more of the modules, units, sub-units according to the embodiments of the present disclosure may be implemented at least partially as a hardware circuit, such as a Field Programmable Gate Array (FPGA), a Programmable Logic Array (PLA), a system on a chip, a system on a substrate, a system on a package, an Application Specific Integrated Circuit (ASIC), or may be implemented in any other reasonable manner of hardware or firmware by integrating or packaging a circuit, or in any one of three implementations of software, hardware, and firmware, or in any suitable combination of any of them. Alternatively, one or more of the modules, sub-modules, units, sub-units according to embodiments of the disclosure may be at least partially implemented as a computer program module, which when executed may perform the corresponding functions.
For example, any plurality of the first obtaining module 510, the first executing module 520 and the processing module 530 may be combined and implemented in one module/unit/sub-unit, or any one of the modules/units/sub-units may be split into a plurality of modules/units/sub-units. Alternatively, at least part of the functionality of one or more of these modules/units/sub-units may be combined with at least part of the functionality of other modules/units/sub-units and implemented in one module/unit/sub-unit. According to an embodiment of the present disclosure, at least one of the first obtaining module 510, the first executing module 520, and the processing module 530 may be implemented at least partially as a hardware circuit, such as a Field Programmable Gate Array (FPGA), a Programmable Logic Array (PLA), a system on a chip, a system on a substrate, a system on a package, an Application Specific Integrated Circuit (ASIC), or may be implemented by hardware or firmware in any other reasonable manner of integrating or packaging a circuit, or may be implemented by any one of three implementations of software, hardware, and firmware, or any suitable combination of any of the three. Alternatively, at least one of the first obtaining module 510, the first executing module 520 and the processing module 530 may be at least partially implemented as a computer program module, which when executed may perform the corresponding functions.
It should be noted that the multiple transaction processing device portion in the embodiment of the present disclosure corresponds to the multiple transaction processing method portion in the embodiment of the present disclosure, and the description of the multiple transaction processing device portion specifically refers to the multiple transaction processing method portion, which is not described herein again.
FIG. 6 schematically illustrates a block diagram of a computer system suitable for implementing the multi-transaction processing method described above, in accordance with an embodiment of the present disclosure. The computer system illustrated in FIG. 6 is only one example and should not impose any limitations on the scope of use or functionality of embodiments of the disclosure.
As shown in fig. 6, a computer system 600 according to an embodiment of the present disclosure includes a processor 601, which can perform various appropriate actions and processes according to a program stored in a Read Only Memory (ROM)602 or a program loaded from a storage section 608 into a Random Access Memory (RAM) 603. Processor 601 may include, for example, a general purpose microprocessor (e.g., a CPU), an instruction set processor and/or associated chipset, and/or a special purpose microprocessor (e.g., an Application Specific Integrated Circuit (ASIC)), among others. The processor 601 may also include onboard memory for caching purposes. Processor 601 may include a single processing unit or multiple processing units for performing different actions of a method flow according to embodiments of the disclosure.
In the RAM 603, various programs and data necessary for the operation of the system 600 are stored. The processor 601, the ROM 602, and the RAM 603 are connected to each other via a bus 604. The processor 601 performs various operations of the method flows according to the embodiments of the present disclosure by executing programs in the ROM 602 and/or RAM 603. It is to be noted that the programs may also be stored in one or more memories other than the ROM 602 and RAM 603. The processor 601 may also perform various operations of the method flows according to embodiments of the present disclosure by executing programs stored in the one or more memories.
According to an embodiment of the present disclosure, system 600 may also include an input/output (I/O) interface 605, input/output (I/O) interface 605 also connected to bus 604. The system 600 may also include one or more of the following components connected to the I/O interface 605: an input portion 606 including a keyboard, a mouse, and the like; an output portion 607 including a display such as a Cathode Ray Tube (CRT), a Liquid Crystal Display (LCD), and the like, and a speaker; a storage section 608 including a hard disk and the like; and a communication section 609 including a network interface card such as a LAN card, a modem, or the like. The communication section 609 performs communication processing via a network such as the internet. The driver 610 is also connected to the I/O interface 605 as needed. A removable medium 611 such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, or the like is mounted on the drive 610 as necessary, so that a computer program read out therefrom is mounted in the storage section 608 as necessary.
According to embodiments of the present disclosure, method flows according to embodiments of the present disclosure may be implemented as computer software programs. For example, embodiments of the present disclosure include a computer program product comprising a computer program embodied on a computer readable storage medium, the computer program containing program code for performing the method illustrated by the flow chart. In such an embodiment, the computer program may be downloaded and installed from a network through the communication section 609, and/or installed from the removable medium 611. The computer program, when executed by the processor 601, performs the above-described functions defined in the system of the embodiments of the present disclosure. The systems, devices, apparatuses, modules, units, etc. described above may be implemented by computer program modules according to embodiments of the present disclosure.
The present disclosure also provides a computer-readable storage medium, which may be contained in the apparatus/device/system described in the above embodiments; or may exist separately and not be assembled into the device/apparatus/system. The computer-readable storage medium carries one or more programs which, when executed, implement the method according to an embodiment of the disclosure.
According to an embodiment of the present disclosure, the computer-readable storage medium may be a non-volatile computer-readable storage medium. Examples may include, but are not limited to: a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the present disclosure, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device.
For example, according to embodiments of the present disclosure, a computer-readable storage medium may include the ROM 602 and/or RAM 603 described above and/or one or more memories other than the ROM 602 and RAM 603.
The flowchart and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present disclosure. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams or flowchart illustration, and combinations of blocks in the block diagrams or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions. Those skilled in the art will appreciate that various combinations and/or combinations of features recited in the various embodiments and/or claims of the present disclosure can be made, even if such combinations or combinations are not expressly recited in the present disclosure. In particular, various combinations and/or combinations of the features recited in the various embodiments and/or claims of the present disclosure may be made without departing from the spirit or teaching of the present disclosure. All such combinations and/or associations are within the scope of the present disclosure.
The embodiments of the present disclosure have been described above. However, these examples are for illustrative purposes only and are not intended to limit the scope of the present disclosure. Although the embodiments are described separately above, this does not mean that the measures in the embodiments cannot be used in advantageous combination. The scope of the disclosure is defined by the appended claims and equivalents thereof. Various alternatives and modifications can be devised by those skilled in the art without departing from the scope of the present disclosure, and such alternatives and modifications are intended to be within the scope of the present disclosure.

Claims (10)

1. A multi-transaction processing method, wherein the multi-transaction comprises at least a first transaction and a second transaction, an output of the first transaction being an input of the second transaction, the method comprising:
obtaining a self-defined annotation configured in the first transaction;
executing a method corresponding to the user-defined annotation to obtain the output of the first transaction; and
and taking the output of the first transaction as the input of the second transaction, and executing the second transaction to realize the multi-transaction processing.
2. The method of claim 1, further comprising:
before executing the method corresponding to the user-defined annotation and obtaining the output of the first transaction, obtaining configuration parameters for representing whether the user-defined annotation is enabled or not;
under the condition that the value of the configuration parameter is a first enumeration value, the user-defined annotation is forbidden;
normally starting the self-defined annotation under the condition that the value of the configuration parameter is a second enumeration value;
when the value of the configuration parameter is a third enumeration value, the user-defined annotation is enabled forcibly; and
and under the condition that the user-defined annotation is normally enabled or forcibly enabled, executing a method corresponding to the user-defined annotation to obtain the output of the first transaction.
3. The method of claim 2, wherein executing the method corresponding to the custom annotation if the custom annotation is forcibly enabled, resulting in the output of the first transaction comprises:
acquiring a custom strategy corresponding to the first transaction;
executing the custom strategy to obtain simulated service data; and
the simulated service data is output as the first transaction.
4. The method of claim 2, wherein, in the case that the custom annotation is normally enabled, executing the method corresponding to the custom annotation, resulting in the output of the first transaction, further comprises:
executing the first transaction; and
and taking the normal output parameter as the output of the first transaction under the condition that the output parameter of the first transaction is normal.
5. The method of claim 2, wherein, in the case that the custom annotation is normally enabled, executing the method corresponding to the custom annotation, resulting in the output of the first transaction, further comprises:
executing the first transaction;
acquiring a custom strategy corresponding to the first transaction under the condition that the output parameter of the first transaction is abnormal;
executing the custom strategy to obtain simulated service data; and
the simulated service data is output as the first transaction.
6. The method of claim 3 or 5, wherein obtaining a custom policy corresponding to the first transaction comprises:
acquiring a user-defined strategy set corresponding to the multiple transactions;
obtaining a custom policy name in a custom annotation configured in the first transaction; and
and acquiring a custom strategy corresponding to the first transaction from the custom strategy set according to the custom strategy name.
7. A multi-transaction processing apparatus, wherein the multi-transaction includes at least a first transaction and a second transaction, an output of the first transaction being an input of the second transaction, the apparatus comprising:
the first acquisition module is used for acquiring the self-defined annotation configured in the first transaction;
the first execution module is used for executing the method corresponding to the user-defined annotation to obtain the output of the first transaction; and
and the processing module is used for taking the output of the first transaction as the input of the second transaction and executing the second transaction so as to realize the multi-transaction processing.
8. The apparatus of claim 7, further comprising:
a second obtaining module, configured to obtain a configuration parameter for characterizing whether the user-defined annotation is enabled or not before the method corresponding to the user-defined annotation is executed and the output of the first transaction is obtained;
the forbidding module is used for forbidding the user-defined annotation under the condition that the value of the configuration parameter is the first enumerated value;
the first enabling module is used for normally enabling the user-defined annotation under the condition that the value of the configuration parameter is the second enumerated value;
the second enabling module is used for forcibly enabling the user-defined annotation under the condition that the value of the configuration parameter is a third enumeration value; and
and the second execution module is used for executing the method corresponding to the self-defined annotation under the condition that the self-defined annotation is normally enabled or forcibly enabled to obtain the output of the first transaction.
9. A computer system, comprising:
one or more processors;
a memory for storing one or more programs,
wherein the one or more programs, when executed by the one or more processors, cause the one or more processors to implement the method of any of claims 1-6.
10. A computer readable storage medium having stored thereon executable instructions which, when executed by a processor, cause the processor to carry out the method of any one of claims 1 to 6.
CN202011289716.XA 2020-11-17 2020-11-17 Multi-transaction processing method, device, computer system and readable storage medium Pending CN113760466A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202011289716.XA CN113760466A (en) 2020-11-17 2020-11-17 Multi-transaction processing method, device, computer system and readable storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202011289716.XA CN113760466A (en) 2020-11-17 2020-11-17 Multi-transaction processing method, device, computer system and readable storage medium

Publications (1)

Publication Number Publication Date
CN113760466A true CN113760466A (en) 2021-12-07

Family

ID=78786136

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202011289716.XA Pending CN113760466A (en) 2020-11-17 2020-11-17 Multi-transaction processing method, device, computer system and readable storage medium

Country Status (1)

Country Link
CN (1) CN113760466A (en)

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102073505A (en) * 2011-01-31 2011-05-25 北京科技大学 Service composition-oriented declarative transaction integration method and system
CN108563567A (en) * 2018-04-09 2018-09-21 平安普惠企业管理有限公司 Automated testing method, device, equipment and computer readable storage medium

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102073505A (en) * 2011-01-31 2011-05-25 北京科技大学 Service composition-oriented declarative transaction integration method and system
CN108563567A (en) * 2018-04-09 2018-09-21 平安普惠企业管理有限公司 Automated testing method, device, equipment and computer readable storage medium

Similar Documents

Publication Publication Date Title
US9928038B2 (en) Dynamically building locale objects or subsections of locale objects based on historical data
US9536023B2 (en) Code generation for using an element in a first model to call a portion of a second model
US20180129592A1 (en) Mock-based unit test(s) for an end-to-end test of a code snippet
US9058193B2 (en) Methods and systems for providing compatibility of applications with multiple versions of an operating system
CN111357241A (en) System and method for integrating cloud applications into a cloud service broker platform using automated generic connector encapsulation
US20130151571A1 (en) Interface defined virtual data fields
CN112930530B (en) Client application for network application execution
CN111444453A (en) Page return data processing method and device
US9141353B2 (en) Dynamically building locale objects at run-time
CN117009397A (en) Data query method, data query device, electronic equipment and storage medium
CN113176907A (en) Interface data calling method and device, computer system and readable storage medium
CN112732547B (en) Service testing method and device, storage medium and electronic equipment
CN113434582A (en) Service data processing method and device, computer equipment and storage medium
CN113535565B (en) Interface use case generation method, device, equipment and medium
US8997044B2 (en) Overriding system attributes and function returns in a software subsystem
CN112256252A (en) Interface generation method and device, storage medium and electronic equipment
CN112988604B (en) Object testing method, testing system, electronic device and readable storage medium
CN113760466A (en) Multi-transaction processing method, device, computer system and readable storage medium
CN112068814A (en) Method, device, system and medium for generating executable file
CN113392010A (en) Common component testing method and device, electronic equipment and storage medium
CN111859403A (en) Method and device for determining dependency vulnerability, electronic equipment and storage medium
CN113515326B (en) Data conversion method, device, electronic equipment and storage medium
CN115016827A (en) Method, device, electronic equipment and medium for deploying JAVA application
CN113760467A (en) Transaction processing method, device, computer system and storage medium
CN115421738A (en) Version deployment method and device, electronic equipment and storage medium

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