CN112860447A - Interaction method and system between different applications - Google Patents

Interaction method and system between different applications Download PDF

Info

Publication number
CN112860447A
CN112860447A CN201911185619.3A CN201911185619A CN112860447A CN 112860447 A CN112860447 A CN 112860447A CN 201911185619 A CN201911185619 A CN 201911185619A CN 112860447 A CN112860447 A CN 112860447A
Authority
CN
China
Prior art keywords
application
computing task
computing
task
calculation
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.)
Granted
Application number
CN201911185619.3A
Other languages
Chinese (zh)
Other versions
CN112860447B (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 Wodong Tianjun Information Technology Co Ltd
Original Assignee
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 Wodong Tianjun Information Technology Co Ltd filed Critical Beijing Wodong Tianjun Information Technology Co Ltd
Priority to CN201911185619.3A priority Critical patent/CN112860447B/en
Publication of CN112860447A publication Critical patent/CN112860447A/en
Application granted granted Critical
Publication of CN112860447B publication Critical patent/CN112860447B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

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/54Interprogram communication
    • G06F9/546Message passing systems or structures, e.g. queues
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/48Program initiating; Program switching, e.g. by interrupt
    • G06F9/4806Task transfer initiation or dispatching
    • G06F9/4843Task transfer initiation or dispatching by program, e.g. task dispatcher, supervisor, operating system
    • G06F9/4881Scheduling strategies for dispatcher, e.g. round robin, multi-level priority queues
    • 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/50Allocation of resources, e.g. of the central processing unit [CPU]
    • G06F9/5005Allocation of resources, e.g. of the central processing unit [CPU] to service a request
    • G06F9/5027Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resource being a machine, e.g. CPUs, Servers, Terminals
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2209/00Indexing scheme relating to G06F9/00
    • G06F2209/48Indexing scheme relating to G06F9/48
    • G06F2209/482Application
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2209/00Indexing scheme relating to G06F9/00
    • G06F2209/50Indexing scheme relating to G06F9/50
    • G06F2209/5018Thread allocation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2209/00Indexing scheme relating to G06F9/00
    • G06F2209/54Indexing scheme relating to G06F9/54
    • G06F2209/548Queue

Landscapes

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

Abstract

The invention discloses an interaction method and an interaction system among different applications, and relates to the technical field of computers. One embodiment of the method comprises: receiving a service request by using a first application edited by a first language, and generating a computing task according to the service request, wherein the computing task indicates a computing task identifier and an incoming parameter of the computing task; the first application sends the computing task identification to a second application written in a second language; the second application executes the computing task by using the incoming parameters of the computing task according to the computing task identification so as to generate a computing result; and the second application correspondingly stores the calculation result and the calculation task identifier to the message queue so that the first application can obtain the calculation result corresponding to the calculation task from the message queue. The implementation mode realizes interaction or calling among different applications and can decouple the different interactive applications.

Description

Interaction method and system between different applications
Technical Field
The invention relates to the technical field of computers, in particular to an interaction method and system among different applications.
Background
With the development of computer technology, more and more computer languages with different performances, such as Java, C language, Python, PHP, C + + and the like, emerge. Because different languages have different characteristics, for example, Python language has the advantages of high development efficiency, portability, expandability, embeddability and the like, and Java has the advantages of realizing cross-platform and the like. Therefore, in order to combine the advantages of each language and make up for the deficiencies, in the actual development or application process, the calling or interaction between the applications written in different languages is often involved. Specifically, taking call or interaction between a Java application and a Java application as an example for explanation, the following two methods are mainly used in the existing method for implementing interaction between a Java application and a Python application: compiling Python source codes into JVM bytecode through Jython (namely Python realized on JVM), and executing corresponding bytecode by the JVM to realize calling Python application; and executing the Python script file under the specific path by a Runtime method provided in a software development tool of Java languages such as JDK and the like, thereby realizing the calling of Python.
In the process of implementing the invention, the inventor finds that at least the following problems exist in the prior art: the Jython calling method needs Python to convert JVM bytecode, has low execution efficiency, cannot well support a third-party library in a Python program, and has poor expansibility; the Runtime method has high requirements on operating environments, and needs to have two operating environments of Java and Python at the same time; in addition, coupling exists in the process of realizing the interaction of the Java application and the Python application, the Java application and the Python application cannot be used independently, and the expansibility is poor.
Disclosure of Invention
In view of this, the present invention provides an interaction method between applications, which can not only implement interaction or invocation between different applications, such as a Java application and a Python application, but also decouple communication between the different applications through a message queue.
To achieve the above object, according to a first aspect of the present invention, there is provided an interaction method between different applications, including:
receiving a service request by using a first application edited by a first language, and generating a computing task according to the service request, wherein the computing task indicates a computing task identifier and an incoming parameter of the computing task;
the first application sends the computing task identification to a second application written in a second language;
the second application executes the computing task by using the incoming parameters of the computing task according to the computing task identification so as to generate a computing result;
and the second application correspondingly stores the calculation result and the calculation task identifier to the message queue so that the first application can obtain the calculation result corresponding to the calculation task from the message queue.
Optionally, the first application sends the computing task identifier to the second application through one or more of the following interfaces: restful, SOAP, RPC, and HTTP.
Optionally, the first application correspondingly stores the computation task identifier and the incoming parameters of the computation task to the message queue, and sends the computation task identifier to the second application;
the second application acquires the incoming parameters of the computing task from the message queue according to the computing task identification, and executes the computing task by using the incoming parameters of the computing task to generate a computing result
Optionally, the first application sends the computing task identification and the incoming parameters of the computing task to the second application;
the second application executes the computing task using the received incoming parameters of the computing task to generate a computing result.
Optionally, the method further comprises:
prior to sending the computing task identification to the second application, the first application conforms incoming parameters of the computing task to a parameter format required for computing by the second application.
Optionally, the second application selects a thread to execute the computing task for the received computing task identification using a thread pool.
Optionally, when an exception occurs when the second application executes the computing task, the second application stores the exception to the message queue in correspondence with the computing task identifier.
Optionally, the first application written in the first language is a Java application, and the second application written in the second language is a Python application.
Optionally, the Java application is a Java Web application, the service request is generated according to a Web page request from a client, and when an exception occurs when the Java Web application generates an incoming parameter of the computation task according to the Web page request, the exception is sent to the client for display.
To achieve the above object, according to a second aspect of the present invention, there is provided an interactive system between different applications, comprising: a first application written in a first language, a second application written in a second language, and a message queue; wherein the content of the first and second substances,
the first application is used for receiving a service request and generating a computing task according to the service request, wherein the computing task indicates a computing task identifier and an incoming parameter of the computing task;
the first application is further used for sending the computing task identifier to the second application;
the second application is used for executing the computing task by using the incoming parameters of the computing task according to the computing task identification so as to generate a computing result;
the second application is further configured to store the calculation result and the calculation task identifier in the message queue in a corresponding manner, so that the first application obtains the calculation result corresponding to the calculation task from the message queue;
and the message queue is used for correspondingly storing the calculation result and the calculation task identifier.
Optionally, the first application sends the computing task identifier to the second application through one or more of the following interfaces: restful, SOAP, RPC, and HTTP.
Optionally, the first application is further configured to correspondingly store the computation task identifier and incoming parameters of the computation task to the message queue, and send the computation task identifier to the second application;
the second application is further used for acquiring the incoming parameters of the computing task from the message queue according to the computing task identification, and executing the computing task by using the incoming parameters of the computing task to generate a computing result
Optionally, the first application sends the computing task identification and the incoming parameters of the computing task to the second application;
the second application executes the computing task using the received incoming parameters of the computing task to generate a computing result.
Optionally, before sending the computing task identifier to the second application, the first application is further configured to conform the incoming parameters of the computing task to a parameter format required for computing by the second application.
Optionally, the second application is further configured to select a thread for executing the computing task for the received computing task identification using a thread pool.
Optionally, when an exception occurs during the execution of the computing task by the second application, the second application is further configured to store the exception to the message queue in correspondence with the computing task identifier.
Optionally, the first application written in the first language is a Java application, and the second application written in the second language is a Python application.
Optionally, the Java application is a Java Web application, the service request is generated according to a Web page request from a client, and when an exception occurs when the Java Web application generates an incoming parameter of the computation task according to the Web page request, the exception is sent to the client for display.
To achieve the above object, according to a third aspect of the present invention, there is provided a server for application interaction, comprising: one or more processors; storage means for storing one or more programs which, when executed by the one or more processors, cause the one or more processors to implement any of the methods of the interaction method described above.
To achieve the above object, according to a fourth aspect of the present invention, there is provided a computer readable medium having stored thereon a computer program which, when executed by a processor, implements any one of the interaction methods described above.
The invention has the following advantages or beneficial effects: the interaction between the first application and the second application is realized through Restful, SOAP, RPC and HTTP interfaces; meanwhile, data such as incoming parameters and calculation results of calculation tasks during interaction between the first application and the second application are transmitted through the message queue, and asynchronous interaction between the first application and the second application is achieved; in addition, the scheduling of the thread in the thread pool by the second application realizes the concurrent processing of a plurality of computing tasks which need to be executed by the first application for responding to the service request.
Further effects of the above-mentioned non-conventional alternatives will be described below in connection with the embodiments.
Drawings
The drawings are included to provide a better understanding of the invention and are not to be construed as unduly limiting the invention. Wherein:
FIG. 1 is a schematic diagram of a main flow of an interaction method between different applications according to an embodiment of the present invention;
FIG. 2 is a schematic diagram of a main flow of another method of interaction between different applications according to an embodiment of the present invention;
FIG. 3 is a schematic diagram of the main structure of an interactive system between different applications according to an embodiment of the present invention;
FIG. 4 is an exemplary system architecture diagram in which embodiments of the present invention may be employed;
fig. 5 is a schematic block diagram of a computer system suitable for use in implementing a terminal device or server of an embodiment of the invention.
Detailed Description
Exemplary embodiments of the present invention are described below with reference to the accompanying drawings, in which various details of embodiments of the invention are included to assist understanding, and which are to be considered as merely exemplary. Accordingly, those of ordinary skill in the art will recognize that various changes and modifications of the embodiments described herein can be made without departing from the scope and spirit of the invention. Also, descriptions of well-known functions and constructions are omitted in the following description for clarity and conciseness.
Fig. 1 is a schematic diagram of a main flow of an interaction method between different applications according to an embodiment of the present invention. It is understood that the different applications that interact with each other include, but are not limited to, applications written in Java, C language, Python, PHP, C + +, and the like, and specifically, the embodiment of the present invention is described in detail only by taking as an example that the first application written in the first language is a Java application, and the second application written in the second language is a Python application.
As shown in fig. 1, the method for interacting the Java application and the Python application specifically includes the following steps:
step S101, a Java application receives a service request and generates a calculation task according to the service request, wherein the calculation task indicates a calculation task identifier and an incoming parameter of the calculation task.
Java applications include, but are not limited to, Java Web applications, Java App applications, etc., and Python applications also include, but are not limited to, Python Web applications, Python App applications, etc. Because the Java application and the Python application adopt different development languages, and the format of the input parameters that can be supported when the computing task is executed correspondingly is different, before the Java application calls the Python application to execute the computing task, that is, before the computing task identifier is sent to the Python application, the Java application needs to make the input parameters of the computing task conform to the parameter format required by the computation of the Python application. In addition, when a database storing incoming parameters of a computing task corresponding to a Java application such as a Java Web application has a sub-library sub-table, the incoming parameters of the corresponding computing task need to be acquired from one or more partitions or sub-tables of the database.
Specifically, the Java application is a Java Web application for example, the corresponding service request is generated according to a Web page request from the client, and when an exception occurs when the Java Web application generates an incoming parameter of a calculation task according to the Web page request, the exception may be sent to the client for display, so as to prompt a user or a related person to generate the exception by inputting the parameter.
Step S102, the Java application sends the calculation task identifier to the Python application.
The Java application sends the computing task identifier to the Python application through one or more of the following interfaces: restful, SOAP, RPC (remote procedure call), and HTTP. Specifically, still taking the example that the Java application is a Java Web application and the corresponding Python application is a Python Web application as an example, the specific implementation code of the Python algorithm is packaged through Web application frameworks such as flash and Django, and a corresponding Restful interface is provided to the outside of the Java Web application, so that the Java Web application calls the Python Web application through the Restful interface and transmits a calculation task identifier corresponding to a calculation task to be executed to the Python Web application.
Step S103, the Python application executes the computing task by using the transmitted parameters of the computing task according to the computing task identification so as to generate a computing result.
Preferably, the Python application uses a thread pool to identify, for the received computing task, a thread to execute the computing task. That is, the Python application schedules threads for executing the computation tasks through the thread pool, and can simultaneously start a plurality of threads for concurrent processing when a plurality of computation tasks need to be executed; when the execution of a specific computing task is started, acquiring the incoming parameters of the computing task, verifying the format, the size and the like of the incoming parameters of the computing task, and executing the computing task by calling a corresponding Python algorithm implementation method during verification; in addition, if the incoming parameter fails to be checked, an error message is sent to the Java application through a message queue or the like.
It is to be appreciated that the Java application can send the computing task identification and the incoming parameters of the computing task directly to the Python application without passing through a message queue; the Python application may also execute the computing task using the received incoming parameters of the computing task to generate a computing result.
Preferably, the Java application correspondingly stores the computation task identifier and the incoming parameters of the computation task to the message queue, and sends the computation task identifier to the Python application; and the Python application acquires the incoming parameters of the computing task from the message queue according to the computing task identifier, and executes the computing task by using the incoming parameters of the computing task to generate a computing result.
Step S104, the Python application stores the calculation result and the calculation task identifier to the message queue in a corresponding manner, so that the Java application obtains the calculation result corresponding to the calculation task from the message queue.
The problems of interactive coupling, asynchronous processing, traffic cutting and the like of the Java Web application and the Python Web application are solved through a message queue, and the usable message queue comprises but is not limited to: redis, RabbitMQ, RocketMQ, ActiveMQ, Kafka, and the like.
Preferably, when an exception occurs during the execution of the computation task by the Python application, the Python application stores the exception to the message queue in correspondence with the computation task identifier, so that the Java application can acquire a message of the computation task execution exception from the message queue according to the computation task identifier, so as to perform processing such as exception analysis on the execution task with the exception in time.
Based on the interaction method of the Java application and the Python application in the embodiment, the interaction between the Java application and the Python application is realized through Restful, SOAP, RPC and HTTP interfaces; meanwhile, information such as incoming parameters, calculation results, calculation abnormity and the like of a calculation task when the Java application is interacted with the Python application is transmitted through a message queue, so that asynchronous communication between the Java application and the Python application is realized, and interaction between the Java application and the Python application is decoupled; in addition, the concurrent processing of multiple computation tasks requested to be executed by the Java application is realized by scheduling the thread in the thread pool by the Python application, and the execution efficiency of the computation tasks is improved. It is understood that the embodiment of the present invention is described in detail only by taking the first application written in the first language as a Java application and the second application written in the second language as a Python application as an example. However, the different applications that interact with each other by using the interaction method between the different applications provided by this embodiment include, but are not limited to, applications written in Java, C language, Python, PHP, C + +, and other languages.
Referring to fig. 2, on the basis of the foregoing embodiment, an interactive method for a Java application and a Python application is provided, which specifically includes the following steps:
step S201, a Java application receives a service request and generates a calculation task according to the service request, wherein the calculation task indicates a calculation task identifier and an incoming parameter of the calculation task.
Step S202, the Java application correspondingly stores the calculation task identification and the incoming parameters of the calculation task to the message queue.
Before storing the computing task identification and the incoming parameters of the computing task correspondingly to the message queue, the Java application makes the incoming parameters of the computing task conform to a parameter format required by the Python application for computing. And when the Java application is a JavaWeb application and the parameter format required by the calculation of the Python application is abnormal, sending the abnormality to the client for display.
Step S203, the Java application sends the computation task identifier to the Python application through one or more of the following interfaces: restful, SOAP, RPC, and HTTP.
Step S204, the Python application acquires the incoming parameters of the computing task from the message queue according to the computing task identifier.
In step S205, the Python application executes the computation task using the incoming parameters of the computation task to generate a computation result.
The Python application uses a thread pool to select a thread for executing the computing task for the received computing task identification. And under the condition that an exception occurs when the Python application executes the computing task, the Python application stores the exception and the computing task identifier to the message queue correspondingly. Message queues that may be used include, but are not limited to: redis, RabbitMQ, RocketMQ, ActiveMQ, Kafka, and the like.
In step S206, the Python application stores the calculation result and the calculation task identifier in the message queue in a corresponding manner.
Step S207, the Java application obtains the corresponding result of the calculation task from the message queue according to the calculation task identifier.
And under the condition that the Java application is a Java Web application, when the Java Web application acquires the corresponding result of the calculation task from the message queue, performing data cleaning and analysis on the calculation result, and returning the calculation result to the front-end page.
It is understood that the embodiment of the present invention is described in detail only by taking the first application written in the first language as a Java application and the second application written in the second language as a Python application as an example. However, the different applications that interact with each other by using the interaction method between the different applications provided by this embodiment include, but are not limited to, applications written in Java, C language, Python, PHP, C + +, and other languages.
Referring to fig. 3, on the basis of the foregoing embodiments, there is provided an interactive system of a Java application and a Python application, including: java applications, Python applications and message queues; wherein the content of the first and second substances,
the Java application is used for receiving a service request and generating a computing task according to the service request, wherein the computing task indicates a computing task identifier and an incoming parameter of the computing task;
the Java application is further configured to send the computation task identifier to the Python application;
the Python application is used for executing the computing task by using the transmitted parameters of the computing task according to the computing task identifier so as to generate a computing result;
the Python application is further configured to store the calculation result and the calculation task identifier in the message queue in a corresponding manner, so that the Java application can obtain the calculation result corresponding to the calculation task from the message queue;
and the message queue is used for correspondingly storing the calculation result and the calculation task identifier.
Preferably, the Java application sends the computation task identifier to the Python application through one or more of the following interfaces: restful, SOAP, RPC, and HTTP.
Preferably, the Java application is further configured to correspondingly store the computation task identifier and incoming parameters of the computation task to the message queue, and send the computation task identifier to the Python application;
the Python application is further configured to obtain incoming parameters of the computation task from the message queue according to the computation task identifier, and execute the computation task using the incoming parameters of the computation task to generate a computation result
Preferably, the Java application sends the computation task identifier and the incoming parameters of the computation task to the Python application;
the Python application executes the computing task using the received incoming parameters of the computing task to generate a computing result.
Preferably, before sending the computing task identifier to the Python application, the Java application is further configured to conform incoming parameters of the computing task to a parameter format required for computing by the Python application.
Preferably, the Python application is further configured to select a thread for executing the computing task for the received computing task identification using a thread pool.
Preferably, when an exception occurs while the Python application executes the computation task, the Python application is further configured to store the exception to the message queue in correspondence with the computation task identifier.
Preferably, the Java application is a Java Web application, the service request is generated according to a Web page request from a client, and when an exception occurs when the Java Web application generates an incoming parameter of the computation task according to the Web page request, the exception is sent to the client for presentation.
It is understood that the embodiment of the present invention is described in detail only by taking the first application written in the first language as a Java application and the second application written in the second language as a Python application as an example. However, the different applications that interact with the interactive system between the different applications provided by this embodiment include, but are not limited to, applications written in Java, C language, Python, PHP, C + +, and other languages.
Fig. 4 shows an exemplary system architecture 400 to which the interactive method of the Java application and the Python application of the embodiments of the present invention may be applied.
As shown in fig. 4, the system architecture 400 may include terminal devices 401, 402, 403, a network 404, and a server 405. The network 404 serves as a medium for providing communication links between the terminal devices 401, 402, 403 and the server 405. Network 404 may include various types of connections, such as wire, wireless communication links, or fiber optic cables, to name a few.
A user may use terminal devices 401, 402, 403 to interact with a server 405 over a network 404 to receive or send messages or the like. The terminal devices 401, 402, 403 may have various communication client applications installed thereon, such as shopping applications, web browser applications, search applications, instant messaging tools, mailbox clients, social platform software, and the like.
The terminal devices 401, 402, 403 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 405 may be a server that provides various services, such as a background management server that supports shopping websites browsed by users using the terminal devices 401, 402, and 403. The background management server may analyze and perform other processing on the received data such as the product information query request, and feed back a processing result (e.g., a calculation result of the calculation task) to the terminal device.
It should be noted that the interaction method between the Java application and the Python application provided in the embodiment of the present invention is generally executed by the server 405.
It should be understood that the number of terminal devices, networks, and servers in fig. 4 is merely illustrative. There may be any number of terminal devices, networks, and servers, as desired for implementation.
Referring now to FIG. 5, shown is a block diagram of a computer system 500 suitable for use with a terminal device implementing an embodiment of the present invention. The terminal device shown in fig. 5 is only an example, and should not bring any limitation to the functions and the scope of use of the embodiments of the present invention.
As shown in fig. 5, the computer system 500 includes a Central Processing Unit (CPU)501 that can perform various appropriate actions and processes according to a program stored in a Read Only Memory (ROM)502 or a program loaded from a storage section 508 into a Random Access Memory (RAM) 503. In the RAM 503, various programs and data necessary for the operation of the system 500 are also stored. The CPU 501, ROM 502, and RAM 503 are connected to each other via a bus 504. An input/output (I/O) interface 505 is also connected to bus 504.
The following components are connected to the I/O interface 505: an input portion 506 including a keyboard, a mouse, and the like; an output portion 507 including a display such as a Cathode Ray Tube (CRT), a Liquid Crystal Display (LCD), and the like, and a speaker; a storage portion 508 including a hard disk and the like; and a communication section 509 including a network interface card such as a LAN card, a modem, or the like. The communication section 509 performs communication processing via a network such as the internet. The driver 510 is also connected to the I/O interface 505 as necessary. A removable medium 511 such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, or the like is mounted on the drive 510 as necessary, so that a computer program read out therefrom is mounted into the storage section 508 as necessary.
In particular, according to the embodiments of the present disclosure, the processes described above with reference to the flowcharts 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 medium, the computer program comprising program code for performing the method illustrated in the flow chart. In such an embodiment, the computer program may be downloaded and installed from a network through the communication section 509, and/or installed from the removable medium 511. The computer program performs the above-described functions defined in the system of the present invention when executed by the Central Processing Unit (CPU) 501.
It should be noted that the computer readable medium shown in the present invention can be a computer readable signal medium or a computer readable storage medium or any combination of the two. A computer readable storage medium may be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the foregoing. More specific examples of the computer readable storage medium may include, but are not limited to: an electrical connection having one or more wires, 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), an optical fiber, 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 invention, 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. In the present invention, however, a computer readable signal medium may include a propagated data signal with computer readable program code embodied therein, for example, in baseband or as part of a carrier wave. Such a propagated data signal may take many forms, including, but not limited to, electro-magnetic, optical, or any suitable combination thereof. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, fiber optic cable, RF, etc., or any suitable combination of the foregoing.
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 invention. 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.
As another aspect, the present invention also provides a computer-readable medium that may be contained in the apparatus described in the above embodiments; or may be separate and not incorporated into the device. The computer readable medium carries one or more programs which, when executed by a device, cause the device to comprise: the method comprises the steps that a Java application receives a service request and generates a computing task according to the service request, wherein the computing task indicates a computing task identifier and an incoming parameter of the computing task; the Java application sends the computing task identifier to the Python application; the Python application executes the computing task by using the transmitted parameters of the computing task according to the computing task identifier to generate a computing result; and the Python application correspondingly stores the calculation result and the calculation task identifier to the message queue so that the Java application can obtain the calculation result corresponding to the calculation task from the message queue.
According to the technical scheme of the embodiment of the invention, the interaction between the first application and the second application is realized through Restful, SOAP, RPC and HTTP interfaces; meanwhile, data such as incoming parameters and calculation results of calculation tasks during interaction between the first application and the second application are transmitted through the message queue, and asynchronous interaction between the first application and the second application is achieved; in addition, the scheduling of the thread in the thread pool by the second application realizes the concurrent processing of a plurality of computing tasks which need to be executed by the first application for responding to the service request.
The above-described embodiments should not be construed as limiting the scope of the invention. Those skilled in the art will appreciate that various modifications, combinations, sub-combinations, and substitutions can occur, depending on design requirements and other factors. Any modification, equivalent replacement, and improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention.

Claims (12)

1. A method for interaction between different applications, comprising:
receiving a service request by using a first application edited by a first language, and generating a computing task according to the service request, wherein the computing task indicates a computing task identifier and an incoming parameter of the computing task;
the first application sends the computing task identification to a second application written in a second language;
the second application executes the computing task by using the incoming parameters of the computing task according to the computing task identification so as to generate a computing result;
and the second application correspondingly stores the calculation result and the calculation task identifier to the message queue so that the first application can obtain the calculation result corresponding to the calculation task from the message queue.
2. The method of claim 1,
the first application sends the computing task identification to the second application through one or more of the following interfaces: restful, SOAP, RPC, and HTTP.
3. The method of claim 1,
the first application correspondingly stores the calculation task identification and the incoming parameters of the calculation task to the message queue and sends the calculation task identification to the second application;
and the second application acquires the incoming parameters of the computing task from the message queue according to the computing task identification, and executes the computing task by using the incoming parameters of the computing task to generate a computing result.
4. The method of claim 1,
the first application sends the computing task identification and the incoming parameters of the computing task to the second application;
the second application executes the computing task using the received incoming parameters of the computing task to generate a computing result.
5. The method for interacting between different applications as recited in claim 1, further comprising:
prior to sending the computing task identification to the second application, the first application conforms incoming parameters of the computing task to a parameter format required for computing by the second application.
6. The method of claim 1,
the second application selects a thread to execute the computing task for the received computing task identification using a thread pool.
7. The method of claim 1,
and under the condition that an exception occurs when the second application executes the computing task, the second application stores the exception and the computing task identifier to the message queue correspondingly.
8. The method according to any one of claims 1 to 7, wherein the first application written in the first language is a Java application and the second application written in the second language is a Python application.
9. The method of claim 8,
the Java application is a Java Web application, the service request is generated according to a webpage request from a client, and when an exception occurs when the Java Web application generates the input parameters of the calculation task according to the webpage request, the exception is sent to the client for display.
10. An interactive system between different applications, comprising: a first application written in a first language, a second application written in a second language, and a message queue; wherein the content of the first and second substances,
the first application is used for receiving a service request and generating a computing task according to the service request, wherein the computing task indicates a computing task identifier and an incoming parameter of the computing task;
the first application is further used for sending the computing task identifier to the second application;
the second application is used for executing the computing task by using the incoming parameters of the computing task according to the computing task identification so as to generate a computing result;
the second application is further configured to store the calculation result and the calculation task identifier in the message queue in a corresponding manner, so that the first application obtains the calculation result corresponding to the calculation task from the message queue;
and the message queue is used for correspondingly storing the calculation result and the calculation task identifier.
11. A server for application interaction, comprising:
one or more processors;
a storage device for storing one or more programs,
when executed by the one or more processors, cause the one or more processors to implement the method of any one of claims 1-9.
12. A computer-readable medium, on which a computer program is stored, which, when being executed by a processor, carries out the method according to any one of claims 1-9.
CN201911185619.3A 2019-11-27 2019-11-27 Interaction method and system between different applications Active CN112860447B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201911185619.3A CN112860447B (en) 2019-11-27 2019-11-27 Interaction method and system between different applications

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201911185619.3A CN112860447B (en) 2019-11-27 2019-11-27 Interaction method and system between different applications

Publications (2)

Publication Number Publication Date
CN112860447A true CN112860447A (en) 2021-05-28
CN112860447B CN112860447B (en) 2024-06-18

Family

ID=75985779

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201911185619.3A Active CN112860447B (en) 2019-11-27 2019-11-27 Interaction method and system between different applications

Country Status (1)

Country Link
CN (1) CN112860447B (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113645303A (en) * 2021-08-11 2021-11-12 曙光信息产业(北京)有限公司 Data transmission method and device, computer equipment and storage medium

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20150220375A1 (en) * 2014-01-31 2015-08-06 Corero Networks Security, Inc. Systems and methods of interface description language (idl) compilers
CN106325866A (en) * 2016-08-22 2017-01-11 网易(杭州)网络有限公司 Cross-engine calling method and cross-engine calling device
CN107632894A (en) * 2017-08-09 2018-01-26 中国电力科学研究院 A kind of implementation method and device for power market transaction service call

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20150220375A1 (en) * 2014-01-31 2015-08-06 Corero Networks Security, Inc. Systems and methods of interface description language (idl) compilers
CN106325866A (en) * 2016-08-22 2017-01-11 网易(杭州)网络有限公司 Cross-engine calling method and cross-engine calling device
CN107632894A (en) * 2017-08-09 2018-01-26 中国电力科学研究院 A kind of implementation method and device for power market transaction service call

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
梅雪峰, 赵文静: "基于消息队列和Web服务的分布式系统异步交互方式体系架构", 西北大学学报(自然科学版), no. 06 *

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113645303A (en) * 2021-08-11 2021-11-12 曙光信息产业(北京)有限公司 Data transmission method and device, computer equipment and storage medium
CN113645303B (en) * 2021-08-11 2024-04-23 曙光信息产业(北京)有限公司 Data transmission method, device, computer equipment and storage medium

Also Published As

Publication number Publication date
CN112860447B (en) 2024-06-18

Similar Documents

Publication Publication Date Title
CN111338623B (en) Method, device, medium and electronic equipment for developing user interface
CN113010405A (en) Application program testing method and device
CN111309304B (en) Method, device, medium and electronic equipment for generating IDL file
CN110888639A (en) Business code compiling and packaging method and device
CN110807535A (en) Construction method and construction device of unified reservation platform and unified reservation platform system
CN113360377A (en) Test method and device
CN112860447B (en) Interaction method and system between different applications
CN110275701B (en) Data processing method, device, medium and computing equipment
CN111414154A (en) Method and device for front-end development, electronic equipment and storage medium
CN112685481A (en) Data processing method and device
CN113779122B (en) Method and device for exporting data
CN111488268A (en) Dispatching method and dispatching device for automatic test
CN110851194A (en) Method and device for acquiring code for realizing new interface
CN110806967A (en) Unit testing method and device
CN112463616A (en) Chaos testing method and device for Kubernetes container platform
CN113779018A (en) Data processing method and device
CN113760274A (en) Front-end component logic injection method and device
CN113760693A (en) Method and apparatus for local debugging of microservice systems
CN113468041A (en) Interface comparison test method and device
CN113448652A (en) Request processing method and device
CN113010174A (en) Service monitoring method and device
CN112559001A (en) Method and device for updating application
CN112131095A (en) Pressure testing method and device
CN110727739B (en) Data storage method and device
CN110858240A (en) Front-end module loading 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