CN113296898B - Asynchronous task processing method and device, electronic equipment and storage medium - Google Patents

Asynchronous task processing method and device, electronic equipment and storage medium Download PDF

Info

Publication number
CN113296898B
CN113296898B CN202110577404.7A CN202110577404A CN113296898B CN 113296898 B CN113296898 B CN 113296898B CN 202110577404 A CN202110577404 A CN 202110577404A CN 113296898 B CN113296898 B CN 113296898B
Authority
CN
China
Prior art keywords
converted
middleware
execution
asynchronous task
asynchronous
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.)
Active
Application number
CN202110577404.7A
Other languages
Chinese (zh)
Other versions
CN113296898A (en
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 Zhenshi Information Technology Co Ltd
Original Assignee
Beijing Jingdong Zhenshi 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 Zhenshi Information Technology Co Ltd filed Critical Beijing Jingdong Zhenshi Information Technology Co Ltd
Priority to CN202110577404.7A priority Critical patent/CN113296898B/en
Publication of CN113296898A publication Critical patent/CN113296898A/en
Application granted granted Critical
Publication of CN113296898B publication Critical patent/CN113296898B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

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/465Distributed object oriented systems
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • 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/54Interprogram communication
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2209/00Indexing scheme relating to G06F9/00
    • G06F2209/54Indexing scheme relating to G06F9/54
    • G06F2209/547Messaging middleware

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Software Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Stored Programmes (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The invention discloses an asynchronous task processing method, an asynchronous task processing device, electronic equipment and a storage medium, wherein the method comprises the following steps: determining a code block to be converted in a target engineering file according to an asynchronous task identifier defined by a middleware filing file package, wherein the middleware filing file package comprises at least one running file of a middleware; storing the execution parameters of the code blocks to be converted into a persistent storage space corresponding to the intermediate filing package; and reflecting and calling the code block to be converted based on the execution parameters so as to realize asynchronous execution of the code block to be converted. According to the embodiment of the invention, the execution parameters are stored in the persistent storage space, so that asynchronous execution of the code blocks is realized, the development difficulty is reduced by using the middleware archive file, the coupling degree of the service system and the middleware is reduced, and the later maintenance difficulty of the service system can be reduced.

Description

Asynchronous task processing method and device, electronic equipment and storage medium
Technical Field
The embodiment of the invention relates to the technical field of computer application, in particular to an asynchronous task processing method, an asynchronous task processing device, electronic equipment and a storage medium.
Background
With the development of internet technology, the living aspects gradually depend on respective digital systems, and in the digital systems, the distributed systems are gradually and widely applied due to the advantages of resource sharing, high computing speed, high reliability and the like. Distributed asynchronous tasks are often realized through a middleware technology in the development and use process of a distributed system, however, the existing middleware technology has the following technical problems when realizing the distributed asynchronous tasks:
1. at present, the main stream middleware technology has complex functions, and needs developers to spend a great deal of time to learn related function configuration and function use;
2. In the process of realizing the asynchronous task, a developer needs to realize an interface or inheritance abstract class provided by a middleware, and the level of the developer causes great difference in the execution efficiency of the asynchronous task in the distributed system, so that the execution efficiency of the asynchronous task is reduced;
3. The middleware and the distributed service system are high in coupling degree, and are not beneficial to operation maintenance, upgrading and development of the distributed service system.
Disclosure of Invention
The invention provides an asynchronous task processing method, an asynchronous task processing device, electronic equipment and a storage medium, so as to realize the execution of an asynchronous task, simplify the execution realization process of the asynchronous task based on a middleware filing file package, reduce the coupling degree of a middleware and a service system, and reduce the maintenance and upgrading difficulty of the service system.
In a first aspect, an embodiment of the present invention provides an asynchronous task processing method, where the method includes:
Determining a code block to be converted in a target engineering file according to an asynchronous task identifier defined by a middleware filing file package, wherein the middleware filing file package comprises at least one running file of a middleware;
storing the execution parameters of the code blocks to be converted into a persistent storage space corresponding to the intermediate filing package;
and reflecting and calling the code block to be converted based on the execution parameters so as to realize asynchronous execution of the code block to be converted.
In a second aspect, an embodiment of the present invention further provides an asynchronous task processing device, where the device includes:
the code determining module is used for determining a code block to be converted in the target engineering file according to an asynchronous task identifier defined by a middleware filing file package, wherein the middleware filing file package comprises at least one running file of a middleware;
The parameter storage module is used for storing the execution parameters of the code blocks to be converted into the persistent storage space corresponding to the intermediate archive file package;
and the asynchronous execution module is used for calling the code block to be converted based on the execution parameter reflection so as to realize asynchronous execution of the code block to be converted.
In a third aspect, an embodiment of the present invention further provides an electronic device, including:
one or more processors;
a memory for storing one or more programs,
The one or more programs, when executed by the one or more processors, cause the one or more processors to implement the asynchronous task processing method as described in any of the embodiments of the present invention.
In a fourth aspect, embodiments of the present invention further provide a computer readable storage medium having stored thereon a computer program which, when executed by a processor, implements an asynchronous task processing method according to any of the embodiments of the present invention.
According to the embodiment of the invention, the code blocks to be converted in the target engineering file are determined by using the asynchronous task identifier defined by the middleware filing package, the execution parameters of the code blocks to be converted are stored in the persistent storage space created by the middleware filing package, the code to be converted is reflected and called according to the stored support parameters, the execution of the asynchronous task is realized, the development difficulty is reduced by using the middleware filing package, the functional efficiency of the middleware is unified, the execution parameters are cached based on the storage space provided by the middleware filing package, the code to be converted is executed by using a reflection and calling mode, the coupling degree of the middleware code and the service code is reduced, and the maintenance and upgrading difficulty of the service system can be reduced.
Drawings
FIG. 1 is a flow chart of an asynchronous task processing method according to a first embodiment of the present invention;
FIG. 2 is a flowchart of an asynchronous task processing method according to a second embodiment of the present invention;
FIG. 3 is a diagram illustrating an asynchronous task processing method according to a second embodiment of the present invention;
FIG. 4 is a schematic structural diagram of an asynchronous task processing device according to a third embodiment of the present invention;
Fig. 5 is a schematic structural diagram of an electronic device according to a fourth embodiment of the present invention.
Detailed Description
The invention is described in further detail below with reference to the drawings and examples. It is to be understood that the specific embodiments described herein are merely illustrative of the invention and are not limiting thereof. It should be noted that, for convenience of description, only some, but not all of the structures related to the present invention are shown in the drawings, and furthermore, embodiments of the present invention and features in the embodiments may be combined with each other without conflict.
Example 1
Fig. 1 is a flowchart of an asynchronous task processing method provided in an embodiment of the present invention, where the embodiment of the present invention is applicable to an abnormal task call, the method may be performed by an asynchronous task processing device, and the device may be implemented in hardware and/or software, and referring to fig. 1, the method provided in the embodiment of the present invention specifically includes the following steps:
step 110, determining a code block to be converted in a target engineering file according to an asynchronous task identifier defined by a middleware filing file package, wherein the middleware filing file package comprises at least one running file of a middleware.
The middleware ARchive file package may include one or more supporting files used by middleware running, the middleware ARchive file may be used for deploying and running the middleware, and the middleware ARchive file may be a Java ARchive (JAR) file package or a Web ARchive (WAR) file package for implementing asynchronous task execution. The asynchronous task identification may be identification information identifying an asynchronous task, the asynchronous task identification may be composed of text, letters, and numbers, the asynchronous task identification may be defined by a middleware archive package, and an annotation class of an asynchronous task standard may be included in the middleware archive package. The target engineering file may be one or more code files for implementing the service system, code files and configuration files for implementing service functions in the target engineering file, etc. The code blocks to be converted may be class code or method code that requires asynchronous calls, and the code blocks to be converted may include processing logic that implements business functions.
In the embodiment of the invention, the code blocks to be converted in the target engineering file can be marked in advance by using the asynchronous task identifiers, so that the asynchronous task identifiers in the target engineering file can be obtained in a character matching or character recognition mode when the asynchronous execution of the code blocks to be converted can be realized, the code blocks marked by the asynchronous task identifiers can be used as the code blocks to be converted, and it can be understood that the mode of marking the code blocks to be converted by the asynchronous task identifiers can comprise marking at the beginning or the end of the code blocks to be converted.
And 120, storing the execution parameters of the code blocks to be converted into a persistent storage space corresponding to the middleware filing package.
The execution parameters may be parameter information used when the code block to be converted is called, and may include parameters of the code block to be converted, parameters transmitted by an external method, and the like, and the parameter information may include method signature, parameter entry, annotation parameters, and the like. The persistent storage space may be a storage area for storing execution parameters, and may be created by means of a middleware archive package, for example, the middleware archive package may have a creation instruction of the persistent storage space encapsulated therein, and the creation of the persistent storage space may be achieved by calling the middleware archive package creation instruction.
Specifically, the execution parameters in the code block to be converted may be extracted and stored in the persistent storage space created by means of the middleware archive package, and the extraction timing of the execution parameters may depend on the type of the execution parameters in the code block to be converted, for example, for the internal parameters belonging to the code block to be converted itself may be extracted into the persistent storage space before the execution of the code block to be converted, for the execution parameters belonging to the external parameters of the code block to be converted, the execution parameters may be extracted into the persistent storage space during the calling process of the code block to be converted, and further, for reducing the time occupation of the extraction process, all the execution parameters may be directly extracted into the persistent storage space during the calling process of the code block to be converted.
And 130, calling the code block to be converted based on the execution parameter reflection so as to realize asynchronous execution of the code block to be converted.
The method for dynamically linking the program component can be carried out on the code block to be converted by the reflection call, and the call of the code block to be converted can be realized through the execution parameters.
In the embodiment of the invention, when asynchronous task calling can be performed, the execution parameters stored in the persistent storage space can be acquired, and the code blocks to be converted are reflected and called based on the execution parameters, so that asynchronous execution of the code blocks to be converted is realized.
According to the embodiment of the invention, the code blocks to be converted in the target engineering file are determined by using the asynchronous task identification defined by the middleware filing package, the execution parameters of the code blocks to be converted are stored in the persistent storage space created by the middleware filing package, the code to be converted is reflected and called according to the stored support parameters, the execution of the asynchronous task is realized, the development difficulty is reduced by using the middleware filing package, the functional efficiency of the middleware is unified, the execution parameters are cached based on the storage space provided by the middleware filing package, the code to be converted is executed by using a reflection and calling mode, the coupling degree of the intermediate code and the service code is reduced, and the maintenance and upgrading difficulty of the service system can be reduced.
Example two
Fig. 2 is a flowchart of an asynchronous task processing method provided by a second embodiment of the present invention, where the embodiment of the present invention is embodied on the basis of the foregoing embodiment of the present invention, and referring to fig. 2, the method provided by the embodiment of the present invention specifically includes the following steps:
step 210, configuring a middleware archive package, and using the asynchronous task identification as an annotation of the code block to be converted in the modification target file.
In the embodiment of the invention, before asynchronous tasks are executed, a middleware archive package can be configured, the middleware archive package can be processed into a target engineering file, and configuration files required by the middleware archive package operation are created, for example, objects of various types in the middleware archive package are created, and a persistent storage space on which the middleware archive package depends is created.
Specifically, before asynchronous execution of the code blocks to be converted can be achieved, the asynchronous task identifier defined by the middleware archive file can be used for annotating the code blocks to be converted in the target file, for example, the code blocks to be converted in the target file can be matched according to parameters input by a user, and the asynchronous task identifier can be added before the code blocks to be converted as code annotation.
Further, on the basis of the above embodiment of the present invention, the asynchronous task identifier at least includes an asynchronous class annotation identifier and an asynchronous method annotation identifier.
In the embodiment of the invention, the abnormal task identifier may include an asynchronous class annotation identifier for converting a class to be asynchronously executed and an asynchronous method annotation identifier for converting a method to be asynchronously executed, for example, the asynchronous class annotation identifier may be @ ScheduleBean, the asynchronous method annotation identifier may be @ ScheduleAsync, and class codes and method codes may be annotated respectively by using the asynchronous method annotation identifier and the asynchronous class annotation identifier in the development process of the target engineering file, which indicates that the class codes and the method codes need to be asynchronously executed.
And 220, determining the code blocks to be converted in the target engineering file according to the asynchronous task identification defined by the middleware filing file package.
And 230, when the code block to be converted is called, extracting the execution parameters of the code block to be converted by using a tangent plane technology, wherein the execution parameters at least comprise one of a method signature, a parameter and an annotation parameter.
The slicing technique may be a technique of separating functional codes and business logic codes, and may change actually executed processing logic in the execution process of the code block to be converted.
Specifically, a tangent plane technology can be used in the process of calling the code block to be converted, so that processing logic for extracting the execution parameters of the code block to be converted is executed when the code block to be converted is called, and the method signature, the parameter entry, the annotation parameters and other execution parameters of the code block to be converted are extracted in the process of calling the code block to be converted, wherein the method signature can be the method name and the parameter type of the code block to be converted, the parameter entry can be the parameter transmitted in the process of calling the code block to be converted, and the annotation parameters can be parameters supported by the annotation of the code block to be converted.
Step 240, storing the execution parameters in the persistent storage space.
In the embodiment of the invention, the extracted supporting parameters can be stored in a persistent storage space, and the persistent storage space can be one or more of a storage table, a storage database and a storage file, and can be created in the configuration process of a middleware archiving package. It will be appreciated that the execution parameters may be extracted and stored in a persistent memory space each time a block of code to be converted is called, and that the persistent memory space may hold one or more sets of execution parameters.
Step 250, deserializing the execution parameters when triggering asynchronous task scheduling.
The asynchronous task scheduling can be trigger information for triggering asynchronous execution of the code blocks to be converted, the asynchronous task scheduling can be automatically generated by a service system or manually input by a user, and the reverse serialization can be a process for recovering a byte sequence into a code object, so that execution parameters are convenient to execute in the code blocks to be converted.
Specifically, when asynchronous task scheduling is triggered, execution parameters in the persistent storage space can be acquired, deserialization processing is performed on the execution parameters, and the execution parameters in the form of byte sequences are converted into executable objects.
Step 260, calling the code block to be converted according to the anti-serialization execution parameter reflection.
Specifically, the original service processing logic of the code block to be converted can be recalled by using the inversely sequenced execution parameters in a reflection calling mode, so that asynchronous execution of the code block to be converted is realized.
According to the embodiment of the invention, the file package is archived by the middleware, the code blocks to be converted in the target file are annotated by the asynchronous task identification, when the code blocks to be converted are called, the execution parameters in the code blocks to be converted are extracted by using the tangent plane technology, the execution parameters are stored into the persistent storage space, when the asynchronous task scheduling is triggered to be the reverse-sequence execution parameters, the code blocks to be converted are called by using the reverse-sequence execution parameters in a reflection way, the asynchronous execution of the task is realized, the execution parameters are extracted in the calling process of the code blocks to be converted by using the tangent plane technology, the extraction time of the execution parameters is reduced, the execution parameters are stored by using the persistent storage space and the asynchronous task scheduling is carried out, the coupling degree of the middleware codes and the service codes is reduced, and the maintenance and upgrading difficulty of the service system can be reduced.
Further, on the basis of the above embodiment of the present invention, the determining the code block to be converted in the target engineering file according to the asynchronous task identifier defined by the middleware archive package includes: acquiring a code block marked as an asynchronous task in the target engineering file; and taking the code blocks as code blocks to be converted for asynchronous execution.
Specifically, the annotation in the target engineering file can be obtained, whether the annotation is an asynchronous task identifier or not is judged, if the annotation is determined to be the asynchronous task identifier, the code block decorated by the annotation is used as a code block to be converted for asynchronous execution, and the code block to be converted can realize asynchronous execution by means of a middleware filing file package.
Further, on the basis of the above embodiment of the present invention, the configuring the middleware archive package includes:
Adding the middleware filing package to a catalog of the target engineering file; creating an asynchronous task execution class, and instantiating a corresponding number of objects of the asynchronous task identifier according to the asynchronous task execution class; creating an object registration class, and registering the object to the target engineering file according to the object registration class; a persistent storage space of the middleware archive package is created, wherein the persistent storage space includes at least one of a storage table, a storage database, and a storage file.
The asynchronous task execution class may be an execution class for realizing asynchronous call of a task, a file of the asynchronous task execution class may be included in a middleware archive file package, and the object registration class may be an execution class for registering an object created by the asynchronous task execution class.
In the embodiment of the invention, the configuration can be performed before the middleware filing package, the configuration content can include adding the middleware filing package to the target engineering file, creating the asynchronous task execution class included in the middleware filing package, creating the number of objects corresponding to the number of asynchronous task identifications by using the created execution class, registering the created objects in the target engineering file by using the object registration class, and creating a persistent storage space used by the middleware filing file in the asynchronous task execution process, wherein the persistent storage space can be a storage table, a storage database or a storage file.
Further, on the basis of the above embodiment of the present invention, the middleware archive package at least includes the following running files: the asynchronous task identifies annotation class files, execution parameter extraction class files, asynchronous task execution class files, object registration class files, and configuration adaptation class files.
Specifically, the intermediate archive package may include files of an asynchronous task identification annotation class, an execution parameter extraction class, a task execution class, an object registration class, a configuration adaptation class, and the like, where the asynchronous task identification annotation class may be an annotation type that provides asynchronous task identification, and a method that provides a class or method that converts to asynchronous execution. The execution parameter extraction class can be a class method for realizing a tangent plane method, and the original outgoing logic can not be executed when the code block to be converted is called, but the logic for realizing the execution parameter extraction class is realized. The task execution class may be a class of instantiation objects that invoke methods annotated when asynchronous task scheduling is triggered. The object registration class may be a class method used when components need to be registered in order to adapt to asynchronously executing tasks, supporting registration at the service center of the target engineering file. The configuration adaptation class can be a class method for ensuring unified management of configuration files of middleware operation.
In an exemplary embodiment, the middleware archive package is specifically a Jar package, where the Jar package may include ScheduleAsync class files and ScheduleBean class files, and the ScheduleAsync class and ScheduleBean class may be annotation class, which are mainly provided for Jar package users to use, modify classes needing to be converted into asynchronization and method bodies converting into asynchronization, and the method blocks modified by the method bodies are converted into data in an asynchronization table during synchronous execution, and reflect execution after being taken out from the table during task scheduling. The Jar packet may further include a ScheduleAsyncAspect class file, scheduleAsyncAspect class may be a slice class, and the code blocks modified by the annotation may enter a slice method during the synchronous execution process, and the original processing logic is not executed any more, and the logic for writing the execution parameters into the task table in the slice method is directly executed. The Schedule Configuration and ScheduleProperties, scheduleXMLLoad files are also included in the JaR package, and ScheduleConfiguration, scheduleProperties, scheduleXMLLoad is a configured adaptation class, so that the configuration required by the middleware or the configuration file is ensured to be generated by the component and converted into the unified configuration of the middleware. The ScheduleRegistJSFService class is used for adapting to the current asynchronous task, and some components are required to be registered in a service center of a remote procedure call (Remote Procedure Call, RPC) service to realize task call, so that the subsequent support of expansion of other asynchronous task components is facilitated. Defaul tScheduleTaskService is a default task execution class, and when the service is started, the class instantiates objects with corresponding numbers according to the code blocks modified by the notes, so that the objects corresponding to each method are called when the task is triggered to be scheduled. ScheduleAsyncTaskService is a registration class, which carries out spring registration on the classes, so that each annotated method is provided with the object instantiated by the class, and the objects are uniformly registered in the spring, thereby realizing uniform call management.
In an exemplary implementation manner, fig. 3 is an exemplary diagram of an asynchronous task processing method provided by the second embodiment of the present invention, referring to fig. 3, a pre-packaged Jar package of an asynchronous task middleware may be used in an engineering file, after the Jar package is introduced, an accessor of the middleware does not need to pay attention to a specific usage rule of the middleware, only needs to pay attention to service implementation, after modifying an annotation provided by using the Jar package in a method for converting an asynchronous task, the conversion of the asynchronous task may be automatically implemented, and the configuration of an asynchronous task execution parameter may be implemented by changing a unified configuration item in the Jar package. The asynchronous task execution method provided by the embodiment of the invention specifically comprises the following steps:
1. The code blocks in the decoration code file that need to be asynchronously transferred are first annotated with @ ScheduleBean and @ ScheduleAsync defined in the Jar package.
2. The modified code block is processed by using Spring cutting technology, and when the modified code block is executed, the actual logic in the code block is not executed any more, and the cutting method is executed. The method for cutting the surface mainly writes the method signature, parameter entering and parameter supporting by annotating of the modified code block into a unified task table for persistence, and the task table can be created in the process of introducing the Jar package; each call to each code block is persisted as an asynchronous task to the task table. The method comprises the steps of respectively annotating the method class and entering the parameters of the section by the general annotation method class, acquiring a signature by the parameters of the section by the original method; obtaining parameters configured in annotation by using annotation method class as an entry; finally, the original code blocks are not executed any more through the tangent plane technology, and all information is written into an established unified task table, wherein the task table can comprise fields such as a task type, a message body, a method signature, a service main key, a service attribute, a task state, the execution times, creation time, expected execution time, update time, a timestamp and the like.
3. When the project is started, a class for executing the asynchronous task is realized by default, different instances are initialized to register in the running project according to the code blocks modified by the notes, the registered instances can be called through different triggering logics according to different processing logics of the packaged asynchronous task middleware, for example, a class can be used for triggering the calling of the service registered by the project by using a class platform, after the calling is triggered, the task obtaining logic is triggered, after the task is obtained, the data which are reversely sequenced are executed through reflection according to the method signature, parameter entering and other information which are persisted in the data table, and therefore the aim of executing the code blocks asynchronously is achieved.
Example III
Fig. 4 is a schematic structural diagram of an asynchronous task processing device according to a third embodiment of the present invention, where the device shown in fig. 4 may execute the asynchronous task processing method according to any embodiment of the present invention, and has corresponding functional modules and beneficial effects of the execution method, and the device may be implemented by software and/or hardware, and specifically includes: a code determination module 301, a parameter storage module 302 and an asynchronous execution module 303.
The code determining module 301 is configured to determine a code block to be converted in a target engineering file according to an asynchronous task identifier defined by a middleware archiving package, where the middleware archiving package includes at least one running file of a middleware.
And the parameter storage module 302 is configured to store the execution parameters of the code blocks to be converted into the persistent storage space corresponding to the intermediate archive package.
And the asynchronous execution module 303 is used for calling the code block to be converted based on the execution parameter reflection so as to realize asynchronous execution of the code block to be converted.
According to the embodiment of the invention, the code to be converted in the target engineering file is determined by the code determining module by using the asynchronous task identifier defined by the middleware filing package, the parameter storage module stores the execution parameters of the code to be converted into the persistent storage space created by the middleware filing package, the asynchronous execution module calls the code to be converted in a reflection mode according to the stored support parameters, the execution of the asynchronous task is realized, the development difficulty is reduced by using the middleware filing package, the functional efficiency of the middleware is unified, the execution parameters are cached based on the storage space provided by the middleware filing package, the code to be converted is executed by using the reflection calling mode, the coupling degree of the middleware code and the service code is reduced, and the maintenance and upgrading difficulty of the service system can be reduced.
Further, on the basis of the above embodiment of the present invention, the apparatus includes: and the configuration module is used for configuring the middleware filing file package and taking the asynchronous task identifier as an annotation for modifying the code blocks to be converted in the target engineering file.
Further, on the basis of the above embodiment of the present invention, the configuration module in the apparatus is specifically configured to:
Adding the middleware filing package to a catalog of the target engineering file; creating an asynchronous task execution class, and instantiating a corresponding number of objects of the asynchronous task identifier according to the asynchronous task execution class; creating an object registration class, and registering the object to the target engineering file according to the object registration class; creating a persistent storage space of the middleware archive package, wherein the persistent storage space comprises at least one of a storage table, a storage database and a storage file.
Further, on the basis of the above embodiment of the present invention, the code determining module 301 in the apparatus includes:
And the annotation acquisition unit is used for acquiring the code blocks marked for the asynchronous tasks in the target engineering file.
And the code determining unit is used for determining the code block as a code block to be converted for asynchronous execution.
Further, on the basis of the above embodiment of the present invention, the parameter storage module 302 in the apparatus includes:
and the section execution unit is used for extracting the execution parameters of the code block to be converted by using a section technology when the code block to be converted is called, wherein the execution parameters at least comprise one of a method signature, a parameter entering and an annotation parameter.
And the parameter storage unit is used for storing the execution parameters into the persistent storage space.
Further, on the basis of the above embodiment of the present invention, the asynchronous execution module 303 includes:
and the deserializing unit is used for deserializing the execution parameters when the asynchronous task scheduling is triggered.
And the reflection calling unit is used for calling the code block to be converted in a reflection mode according to the deserialized execution parameters.
Further, on the basis of the embodiment of the invention, the asynchronous task identifier at least comprises an asynchronous class annotation identifier and an asynchronous method annotation identifier.
Furthermore, on the basis of the embodiment of the invention, the middleware filing package in the device at least comprises the following operation files: the asynchronous task identifies annotation class files, execution parameter extraction class files, asynchronous task execution class files, object registration class files, and configuration adaptation class files.
Example IV
Fig. 5 is a schematic structural diagram of an electronic device according to a fourth embodiment of the present invention, and as shown in fig. 5, the electronic device includes a processor 40, a memory 41, an input device 42 and an output device 43; the number of processors 40 in the electronic device may be one or more, one processor 40 being taken as an example in fig. 5; the processor 40, the memory 41, the input means 42 and the output means 43 in the electronic device may be connected by a bus or by other means, in fig. 5 by way of example.
The memory 41 is a computer-readable storage medium that can be used to store software programs, computer-executable programs, and modules, such as program instructions/modules corresponding to the asynchronous task processing method in the embodiment of the present invention (e.g., the code determination module 301, the parameter storage module 302, and the asynchronous execution module 303 in the asynchronous task processing device). The processor 40 executes various functional applications of the electronic device and data processing, i.e., implements the asynchronous task processing method described above, by running software programs, instructions, and modules stored in the memory 41.
The memory 41 may mainly include a storage program area and a storage data area, wherein the storage program area may store an operating system, at least one application program required for functions; the storage data area may store data created according to the use of the terminal, etc. In addition, memory 41 may include high-speed random access memory, and may also include non-volatile memory, such as at least one magnetic disk storage device, flash memory device, or other non-volatile solid-state storage device. In some examples, memory 41 may further include memory located remotely from processor 40, which may be connected to the electronic device via a network. Examples of such networks include, but are not limited to, the internet, intranets, local area networks, mobile communication networks, and combinations thereof.
The input device 42 is operable to receive input numeric or character information and to generate key signal inputs related to user settings and function control of the electronic device. The output means 43 may comprise a display device such as a display screen.
Example five
A fifth embodiment of the present invention also provides a storage medium containing computer-executable instructions, which when executed by a computer processor, are for performing an asynchronous task processing method, the method comprising:
Determining a code block to be converted in a target engineering file according to an asynchronous task identifier defined by a middleware filing file package, wherein the middleware filing file package comprises at least one running file of a middleware;
storing the execution parameters of the code blocks to be converted into a persistent storage space corresponding to the intermediate filing package;
and reflecting and calling the code block to be converted based on the execution parameters so as to realize asynchronous execution of the code block to be converted.
Of course, the storage medium containing computer executable instructions provided in the embodiments of the present invention is not limited to the method operations described above, and may also perform related operations in asynchronous task processing provided in any embodiment of the present invention.
From the above description of embodiments, it will be clear to a person skilled in the art that the present invention may be implemented by means of software and necessary general purpose hardware, but of course also by means of hardware, although in many cases the former is a preferred embodiment. Based on such understanding, the technical solution of the present invention may be embodied essentially or in a part contributing to the prior art in the form of a software product, which may be stored in a computer readable storage medium, such as a floppy disk, a Read-Only Memory (ROM), a random access Memory (Random Access Memory, RAM), a FLASH Memory (FLASH), a hard disk, or an optical disk of a computer, etc., and include several instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) to execute the method according to the embodiments of the present invention.
It should be noted that, in the above embodiment of the asynchronous task processing device, each unit and module included are only divided according to the functional logic, but not limited to the above division, so long as the corresponding functions can be implemented; in addition, the specific names of the functional units are also only for distinguishing from each other, and are not used to limit the protection scope of the present invention.
Note that the above is only a preferred embodiment of the present invention and the technical principle applied. It will be understood by those skilled in the art that the present invention is not limited to the particular embodiments described herein, but is capable of various obvious changes, rearrangements and substitutions as will now become apparent to those skilled in the art without departing from the scope of the invention. Therefore, while the invention has been described in connection with the above embodiments, the invention is not limited to the embodiments, but may be embodied in many other equivalent forms without departing from the spirit or scope of the invention, which is set forth in the following claims.

Claims (9)

1. A method of asynchronous task processing, the method comprising:
Determining a code block to be converted in a target engineering file according to an asynchronous task identifier defined by a middleware filing file package, wherein the middleware filing file package comprises at least one running file of a middleware;
Storing the execution parameters of the code blocks to be converted into a persistent storage space corresponding to the middleware filing file package, wherein the execution parameters are parameter information used when the code blocks to be converted are called, and the execution parameters comprise at least one of method signature, parameter entering and annotation parameters;
reflecting and calling the code blocks to be converted based on the execution parameters so as to realize asynchronous execution of the code blocks to be converted;
Before the code blocks to be converted in the target engineering file are determined according to the asynchronous task identification defined by the middleware archiving package, the method further comprises the following steps:
and configuring the middleware filing file package, and taking the asynchronous task identification as an annotation for modifying the code blocks to be converted in the target engineering file.
2. The method of claim 1, wherein the configuring the middleware archive package comprises:
Adding the middleware filing package to a catalog of the target engineering file;
Creating an asynchronous task execution class, and instantiating a corresponding number of objects of the asynchronous task identifier according to the asynchronous task execution class;
creating an object registration class, and registering the object to the target engineering file according to the object registration class;
creating a persistent storage space of the middleware archive package, wherein the persistent storage space comprises at least one of a storage table, a storage database and a storage file.
3. The method of claim 1, wherein the determining the code blocks to be converted in the target project file based on the asynchronous task identification defined by the middleware archive package comprises:
acquiring a code block marked as an asynchronous task in the target engineering file;
And taking the code blocks as code blocks to be converted for asynchronous execution.
4. The method of claim 1, wherein storing the execution parameters of the code blocks to be converted to the persistent storage space corresponding to the middleware archive package comprises:
when the code block to be converted is called, extracting the execution parameters of the code block to be converted by using a tangent plane technology;
storing the execution parameters to the persistent storage space.
5. The method of claim 1, wherein the reflecting the call to the block of code to be translated based on the execution parameters to enable asynchronous execution of the block of code to be translated comprises:
when asynchronous task scheduling is triggered, deserializing the execution parameters;
and reflecting and calling the code blocks to be converted according to the execution parameters which are deserialized.
6. The method of any of claims 1-5, wherein the middleware archive package includes at least the following running files: the asynchronous task identifies annotation class files, execution parameter extraction class files, asynchronous task execution class files, object registration class files, and configuration adaptation class files.
7. An asynchronous task processing device, the device comprising:
the code determining module is used for determining a code block to be converted in the target engineering file according to an asynchronous task identifier defined by a middleware filing file package, wherein the middleware filing file package comprises at least one running file of a middleware;
the parameter storage module is used for storing the execution parameters of the code blocks to be converted into a persistent storage space corresponding to the middleware filing file package, wherein the execution parameters are parameter information used when the code blocks to be converted are called, and the execution parameters comprise at least one of method signature, parameter entering and annotation parameters;
The asynchronous execution module is used for calling the code block to be converted based on the execution parameter reflection so as to realize asynchronous execution of the code block to be converted;
And the configuration module is used for configuring the middleware filing file package and taking the asynchronous task identifier as an annotation for modifying the code blocks to be converted in the target engineering file.
8. An electronic device, the electronic device comprising:
one or more processors;
a memory for storing one or more programs,
The one or more programs, when executed by the one or more processors, cause the one or more processors to implement the asynchronous task processing method of any of claims 1-6.
9. A computer readable storage medium, on which a computer program is stored, characterized in that the computer program, when being executed by a processor, implements the asynchronous task processing method according to any of claims 1-6.
CN202110577404.7A 2021-05-26 2021-05-26 Asynchronous task processing method and device, electronic equipment and storage medium Active CN113296898B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110577404.7A CN113296898B (en) 2021-05-26 2021-05-26 Asynchronous task processing method and device, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110577404.7A CN113296898B (en) 2021-05-26 2021-05-26 Asynchronous task processing method and device, electronic equipment and storage medium

Publications (2)

Publication Number Publication Date
CN113296898A CN113296898A (en) 2021-08-24
CN113296898B true CN113296898B (en) 2024-05-17

Family

ID=77325145

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110577404.7A Active CN113296898B (en) 2021-05-26 2021-05-26 Asynchronous task processing method and device, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN113296898B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116643733B (en) * 2023-07-26 2023-10-13 北京仁科互动网络技术有限公司 Service processing system and method

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109947771A (en) * 2018-08-20 2019-06-28 中国平安人寿保险股份有限公司 Conversion method, device, equipment and the computer readable storage medium of file type
CN110727521A (en) * 2018-07-17 2020-01-24 北京京东尚科信息技术有限公司 Synchronous-to-asynchronous calling method, device, system, electronic equipment and readable medium
CN112015537A (en) * 2020-09-03 2020-12-01 中国平安财产保险股份有限公司 Method, system, terminal device and storage medium for executing data processing task

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
KR101854975B1 (en) * 2016-02-18 2018-05-04 라인 가부시키가이샤 Method and system for extending function of package file
US10942974B2 (en) * 2017-10-20 2021-03-09 Bank Of America Corporation System for synchronous document captures into an asynchronous archive and document-level archiving reconciliation

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110727521A (en) * 2018-07-17 2020-01-24 北京京东尚科信息技术有限公司 Synchronous-to-asynchronous calling method, device, system, electronic equipment and readable medium
CN109947771A (en) * 2018-08-20 2019-06-28 中国平安人寿保险股份有限公司 Conversion method, device, equipment and the computer readable storage medium of file type
CN112015537A (en) * 2020-09-03 2020-12-01 中国平安财产保险股份有限公司 Method, system, terminal device and storage medium for executing data processing task

Also Published As

Publication number Publication date
CN113296898A (en) 2021-08-24

Similar Documents

Publication Publication Date Title
CN111596969B (en) Software architecture method based on microkernel plus plug-in mode
CN108965355B (en) Method, apparatus and computer readable storage medium for data transmission
CN108023908B (en) Data updating method, device and system
CN111581948B (en) Document analysis method, device, equipment and storage medium
CN112463144B (en) Distributed storage command line service method, system, terminal and storage medium
CN111694857B (en) Method, device, electronic equipment and computer readable medium for storing resource data
CN111767090A (en) Method and device for starting small program, electronic equipment and storage medium
CN111124392A (en) Method for improving high concurrency capability of Internet of things platform rule engine
CN112363845A (en) Data synchronization method of system integration middling station and integration middling station system
CN113296898B (en) Asynchronous task processing method and device, electronic equipment and storage medium
CN108399095B (en) Method, system, device and storage medium for supporting dynamic management of timed tasks
CN113821249A (en) Project development configuration method and device, electronic equipment and readable storage medium
CN109783159A (en) Application starting method and apparatus based on configuration information
CN113645260A (en) Service retry method, device, storage medium and electronic equipment
CN116932147A (en) Streaming job processing method and device, electronic equipment and medium
CN116362336A (en) Model reasoning interaction method, electronic equipment and readable storage medium
CN113312031B (en) Naming service interface of software communication system structure
CN112162840B (en) Coroutine processing and management method based on interrupt reentry mechanism
CN113779122B (en) Method and device for exporting data
CN112134938B (en) Message processing method, device, terminal and computer readable storage medium
CN114756227A (en) Resource release processing method and device
CN114546670A (en) Coroutine-based functional asynchronous data distribution system and method
CN112702270B (en) Node calling method, system and storage medium based on event distribution mechanism
CN109032684B (en) Android system based broadcast plug-in implementation method and terminal
CN116521271A (en) Plug-in module management 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
GR01 Patent grant
GR01 Patent grant