A method and system for cross-language application intercommunication
By building a .NET framework communication middleware between JAVA and C++ systems, the complexity and security issues of cross-language system communication are solved, enabling cross-platform and secure system interaction, reducing coupling, and providing flexible maintenance and extension solutions.
Patent Information
- Application Number
- CN202211197681.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-09-29
- Publication Date
- 2026-02-06
- Estimated Expiration
- 2042-09-29
AI Technical Summary
Communication between Java-based application systems and C++-based client systems is complex. Using JNI technology can cause Java programs to lose their cross-platform compatibility and security, and the native language parts need to be recompiled in different system environments, which poses a risk of crashes.
By building a cross-language communication middleware based on the .NET framework, and using the middleware as a bridge, secure and flexible interaction between JAVA and C++ systems is achieved. The communication middleware interacts with the .NET framework using the HTTP protocol, and asynchronous processing and real-time monitoring are performed through a scheduled task queue and a system health performance monitoring component.
It enables secure and reliable interaction between JAVA and C++ systems, reduces the coupling between systems, improves cross-platform compatibility and system flexibility, and simplifies maintenance and expansion.
Smart Images

Figure CN115794372B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the field of computer software, in particular to a method and system for cross-language application system communication. BACKGROUND
[0002] The communication process between an application system developed based on JAVA language and a client system developed based on C++ language is relatively complex. Although the current prior art JNI can be used to realize the interactive communication between the two systems, the use of JNI technology to interact with the C++ system will make the JAVA program lose two advantages of its own platform: 1. The program is no longer cross-platform. To be cross-platform, the local language part must be recompiled in different system environments. 2. The program is no longer absolutely safe. Improper use of local code can cause the entire program to crash. Therefore, the interaction between two different language systems has become a difficult problem. SUMMARY
[0003] The present application aims to provide a method and system for cross-language application system communication, which builds a bridge for cross-language systems based on.NET, i.e. communication middleware, to make the interaction between the two systems more secure and flexible, and to make the interaction between the systems more secure and reduce the coupling degree between the systems.
[0004] According to an aspect of the present application, a method for cross-language application system communication is provided, which is used for communication between a first language application system and a second language application system, and the method comprises:
[0005] creating communication middleware based on a.NET framework;
[0006] combining the components of the communication middleware with the compiled dynamic link library of the first language application system, so that the communication middleware based on the.NET framework and the first language application system interact and communicate with each other;
[0007] the second language application system interacts and communicates with the communication middleware based on an http protocol.
[0008] According to some embodiments, the method comprises:
[0009] the creation of the communication middleware based on the.NET framework comprises:
[0010] building a hierarchical structure of the communication middleware project, which comprises a control layer, an application service layer, a core layer, a reference layer, an entity definition layer, an attribute definition layer and a library file layer;
[0011] The control layer is an entrance for receiving external requests, the application service layer is used for logical processing service logic of inflow or outflow data, the core layer includes core tool classes and framework components, the reference layer is used for introducing opposite interface related header files and core tool classes, the entity definition layer is used for defining data transmission object entity classes, the attribute definition layer is used for defining attribute files related to configuration, and the library file layer is used for introducing dynamic and static library files of the opposite interface.
[0012] According to some embodiments, the method comprises:
[0013] The first language application system is introduced according to requirements, and related dynamic library files and header files containing first language function interface methods are publicly exposed, the header files include first header files, second header files and third header files, the first header files contain involved interfaces and definition classes of creating connections, the second header files define data types involved in the interfaces, and the third header files define data structures involved in the interfaces.
[0014] According to some embodiments, the method comprises:
[0015] The core layer components of the communication middleware are constructed, and the core layer components include a timing task queue processing component and a system health performance monitoring component.
[0016] The received service request is asynchronously processed in a queue task mode through a timing task component in the timing task queue processing component.
[0017] The working state of related modules in the communication middleware is monitored in real time through the system health performance monitoring component, and the working state includes application server working state, database state, tcp connection state and job queue state.
[0018] According to some embodiments, the method comprises:
[0019] The core layer components are constructed, and the core layer components are used for connecting with the first language application system, login authentication, and initializing the communication middleware through the core layer components when the communication middleware is restarted.
[0020] According to some embodiments, the method comprises:
[0021] The control layer file is constructed, including defining a reference control class for receiving an external system service request, logically processing data and encapsulating into a request data packet with a unique request identifier after receiving the external system service request, and then storing each request data packet in a database through the unique request identifier as a primary key, and transmitting a service interface name of the corresponding service request to a task of the timing task component based on a queue for asynchronous execution.
[0022] According to some embodiments, the method further comprises:
[0023] A configuration information class is constructed for loading necessary information into memory when the communication middleware is started;
[0024] All configuration information in the configuration file is directly read through the configuration information class, and the configuration information includes communication middleware state indicators, job queues, opposite server addresses, accounts, passwords, timeout time settings, and log printing storage paths.
[0025] According to some embodiments, the method further comprises:
[0026] The related configuration information in the configuration information class is read by the core layer component when loaded, and initialization operations are performed on the communication middleware, including network communication checking with the first language application system, creating a tcp connection, logging in, identity authentication, and event registration of interface response callback.
[0027] According to some embodiments, the method further comprises:
[0028] A monitoring class is constructed, which is used to monitor the state of the communication middleware in a visual form, and the health state of the communication middleware is realized in a real-time interface through the class and the system health performance monitoring component of the core library file related to the.NET framework, including data cache server working state, job queue execution state, protocol tcp connection state, and interface service execution state.
[0029] According to some embodiments, the method further comprises:
[0030] A dashboard monitoring interface entry class is constructed, and the contents of the dashboard monitoring are integrated through the class, and the job queue execution in the communication middleware is displayed in an interface mode to realize real-time viewing of the interface service execution state of the communication middleware.
[0031] According to another aspect of the present application, a system for cross-language application system communication is provided, comprising a first language application system, a second language application system and a communication middleware,
[0032] The second language application system sends an http request to the communication middleware;
[0033] The communication middleware receives the request information, and after logical processing, puts it into a job scheduling queue, and completes the job in an asynchronous manner through the queue;
[0034] The communication middleware interacts with the first language system through the tcp protocol one by one for the jobs in the job scheduling queue;
[0035] The communication middleware receives the message or response of the first language application system through event listening, and after logical processing, responds to the second language application system in the form of an http request;
[0036] The communication middleware monitors the execution state of the received request of the second language application system in each stage in real time;
[0037] The working state of each component of the communication middleware is monitored in real time, including the working state of the data cache server, the execution state of the job queue, the connection state of the protocol tcp, and the execution state of the interface service.
[0038] According to another aspect of the present application, an electronic device is provided, comprising:
[0039] A memory, a processor and a computer program stored in the memory and executable on the processor, wherein the processor implements the method according to any one of the above methods when executing the computer program.
[0040] According to another aspect of the present application, a computer program product is provided, comprising a computer program or instructions, which, when executed by a processor, implements the method according to any one of the above methods.
[0041] According to the example embodiments of the present application, the bridge of the cross-language system, i.e. the communication middleware, is built based on.NET, so that the interaction between the two systems is more secure and flexible, and the interaction between the systems is more secure and the coupling degree between the systems is reduced.
[0042] It should be understood that the above general description and the following detailed description are only exemplary and do not limit the present application. BRIEF DESCRIPTION OF DRAWINGS
[0043] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the following will briefly introduce the drawings needed in the embodiment description.
[0044] Figure 1 A flow chart of a method for cross-language application system communication is shown according to an example embodiment of the present application.
[0045] Figure 2 A block diagram of a system for cross-language application system communication is shown according to an example embodiment of the present application.
[0046] Figure 3 An interaction diagram of cross-language application system communication is shown according to an example embodiment of the present application.
[0047] Figure 4 An interface schematic diagram of cross-language application system communication is shown according to an example embodiment of the present application.
[0048] FIG. 5 shows an interface schematic diagram of cross-language application system communication according to another example embodiment of the present application.
[0049] Figure 6 A block diagram of an electronic device according to an example embodiment is shown. DETAILED DESCRIPTION
[0050] Example embodiments now will be described more fully hereinafter with reference to the accompanying drawings. Example embodiments, however, can be implemented in many different forms and should not be construed as limited to the embodiments set forth herein; rather, these embodiments are provided so that this disclosure will be thorough and complete, and will fully convey the scope of example embodiments to those skilled in the art. Like reference numerals refer to like elements throughout the several views.
[0051] Moreover, the described features, structures, or characteristics can be combined in any suitable manner in one or more embodiments. In the following description, numerous specific details are provided to give a thorough understanding of embodiments of the application. One skilled in the relevant art will recognize, however, that the
[0052] The block diagrams in the drawings show only the functional entities and do not necessarily correspond to physically separate entities. That is, the functional entities can be implemented in software, or in one or more hardware modules or integrated circuits, or in different network and / or processor devices and / or microcontroller devices.
[0053] The flowcharts shown in the drawings are only illustrative, and do not necessarily include all the contents and operations / steps, nor are they necessarily executed in the order described. For example, some operations / steps can be further divided, and some operations / steps can be combined or partially combined, so the actual execution order can be changed according to actual conditions.
[0054] It should be understood that although the terms first, second, third, etc. can be used herein to describe various components, these components should not be limited by these terms. These terms are used to distinguish one component from another component. Therefore, the first component discussed below can be referred to as the second component without departing from the teachings of the present application concepts. As used herein, the term "and / or" includes all combinations of any one and / or more of the associated listed items.
[0055] Those skilled in the art can understand that the drawings are only schematic diagrams of example embodiments, and the modules or flows in the drawings are not necessarily required for implementing the present application, and therefore cannot be used to limit the protection scope of the present application.
[0056] The communication process between an application system developed based on JAVA language and a client system developed based on C++ language is relatively complex. Although the existing technology JNI can be used to realize the interactive communication between the two systems, the use of JNI technology for the interaction with the C++ system will make the JAVA program lose its own platform advantages: 1. The program is no longer cross-platform. To be cross-platform, the local language part must be recompiled in different system environments. 2. The program is no longer absolutely safe. Improper use of local code can cause the entire program to crash.
[0057] In view of this, the inventors propose to use.NET-based middleware to build a bridge between the two different language systems, i.e. communication middleware, which not only solves the above problems but also makes the interaction between the two systems more secure and flexible; makes the interaction between the systems more secure and reduces the coupling degree between the systems.
[0058] The use of.NET language to develop the communication middleware not only takes full advantage of the cross-language, cross-platform, security, and support for open Internet standards and protocols of.NET, but also uses its mature components to quickly build a management software with strong interface operability.
[0059] The efficient combination of the core library of.NET and the compiled DLL dynamic link library of C++ can enable the middleware (front-end machine) developed based on the.NET framework to securely and reliably interact with the application system based on C++. Then, the application system based on other languages can interact with the middleware (front-end machine) through the http protocol. In this way, the bottleneck problem of cross-language system interaction is solved, and the coupling degree between systems is reduced. Through a relatively independent middleware, more cross-language system interactions can be compatible, and great convenience is provided for subsequent maintenance and expansion, thereby providing a good solution for daily development.
[0060] The example embodiments of the present application are described below in conjunction with the accompanying drawings.
[0061] Figure 1 A method flowchart for cross-language application system communication according to an example embodiment of the present application is shown.
[0062] Referring to Figure 1 At S101, a communication middleware based on the.NET framework is created.
[0063] According to some embodiments, a communication middleware project based on the.NET 5.0 framework can be created using the development tool Visual Studio 2019, named shgt-trade-futures, and the related startup, build, profiling, and other environment variables are configured.
[0064] According to some embodiments, the communication middleware project is structured in layers, including a control layer, an application service layer, a core layer, a reference layer, an entity definition layer, an attribute definition layer, and a library file layer.
[0065] The control layer is an entrance for receiving external requests. The application service layer is used for logical processing of the incoming or outgoing data. The core layer includes core tool classes and framework components. The reference layer is used to import the header files and core tool classes of the counterpart interface. The entity definition layer is used to define data transmission object entity classes. The attribute definition layer is used to define and configure attribute files. The library file layer is used to import the dynamic and static library files of the counterpart interface.
[0066] For example, the project architecture hierarchy is constructed, which is defined as seven layers of controller, appService, core, qouteApi, generated, property, and lib, respectively; the controller layer is mainly used for receiving external request entry layer, the appService layer is mainly used for logically processing the inflow or outflow data business logic layer, the core layer is mainly some core tool classes and framework components, the qouteApi layer introduces the relevant header files of the opposite interface and the core tool classes, the generated layer is mainly used for defining some dto entity classes, the property layer is mainly used for defining some configuration-related attribute files, and the lib layer is mainly used for introducing the dynamic and static library files of the opposite interface.
[0067] At S103, the.NET framework-based communication middleware is combined with the first language application system compiled dynamic link library through the core layer components of.NET, so as to make the communication middleware interact with the first language application system.
[0068] According to some embodiments, the compiled dynamic library file and the header file containing the first language function interface method are introduced according to requirements, the header file includes a first header file, a second header file, and a third header file, the first header file contains the interface and the definition class of creating connection, the second header file defines the data type involved in the interface, and the third header file defines the data structure involved in the interface.
[0069] According to some embodiments, the core layer components related to the.NET framework are introduced, which include a timing task queue processing component and a system health performance monitoring component; the received service request is processed asynchronously in the form of a queue task through the timing task component in the timing task queue processing component; the working state of the related modules in the communication middleware is monitored in real time through the system health performance monitoring component, including the application server working state, the database state, the tcp connection state, and the job queue state.
[0070] For example, the compiled dynamic library file ctquoteapi.dll of the opposite C++ system is introduced according to requirements, and the header files of the C++ function interface method CTFtdcQuoteApi.h, CTFtdcUserApiDataType.h, and CTFtdcUserApiStruct.h are publicly exposed, wherein the CTFtdcQuoteApi file is the definition class of the interface and creating connection, the CTFtdcUserApiDataType header file defines the data type involved in the interface, and the CTFtdcUserApiStruct file defines the data structure involved in the interface.
[0071] For example, a core class component is constructed, which includes a timing task queue processing component Hangfire, a system health monitoring component HealthChecks, etc. The received service request is processed asynchronously in the form of a queue task through the BackgroundJob timing task component in Hangfire, so as to reduce the processing pressure of the access communication middleware in the case of high concurrency. Through the health performance monitoring component HealthChecks, the working state of some related modules in the communication middleware can be monitored in real time, such as the working state of the application server, the state of the redis database, the state of the tcp connection, the state of the qoute job queue, etc.
[0072] According to some embodiments, a core layer component QuoteApiServer is constructed to connect with the opposite C++ application server and perform login authentication. When the communication middleware is restarted, a series of initialization operations are performed on the communication middleware through the class. When the class is loaded, the related configuration information is read and the initialization work of the communication middleware is started, including network communication check with the opposite server, creation of tcp connection, login, identity authentication, and registration of interface response callback events, etc.
[0073] According to some embodiments, a communication middleware receiving external service request entry layer file is constructed, and a class QuoteApisController is defined in the controller layer to receive external system post requests. When receiving external service requests, the data is logically processed and encapsulated into a request data packet with a unique request id generated in step 8), and then each request parameter data packet is stored in the redis database through the unique request requestId as the primary key, and the corresponding request service interface name is transmitted to the queue-based BackgroundJob task for asynchronous execution.
[0074] According to some embodiments, some related configuration information classes involved in building the communication middleware are constructed, and some necessary information needs to be loaded into the memory in advance when the communication middleware starts; DefaultConfigurationProvider, QuoteApiServerConfiguration, through the QuoteApiServerConfiguration class, all configuration information in the configuration file appsettings.xxx.json can be directly read, including communication middleware state indicators, job queues, partner server addresses, accounts, passwords, timeout settings, and log printing storage paths, etc.; then the configuration information is wrapped by the classes DefaultConfigurationProvider and QuoteApiServerConfiguration for use by the communication middleware.
[0075] According to some embodiments, a unique sequence id class DefaultRequestId is constructed, which uses the redis database increment method to create a unique id sequence number. Since the increment sequence generated by the redis database is generated in time sequence mechanism and provides an external interface, the existing method can be directly called to generate a unique sequence number, and combined with the business scenario, a corresponding tool class can be encapsulated. Thus, a unique identification key is provided for the interface service request and database cache in the communication middleware, which facilitates problem tracking and data cache processing in subsequent service requests.
[0076] In S105, the second language application system interacts with the communication middleware based on the http protocol.
[0077] Here, the second language system can be a system developed in Java language, or a system in other languages.
[0078] According to some embodiments, the control layer file of the communication middleware is constructed, including defining a reference control class, which is used to receive service requests from external systems (i.e. the second language application system). When receiving service requests from external systems, the data is logically processed and encapsulated into a request data packet with a unique request identification, and then each request data packet is stored in the database through the unique request identification as the primary key, and the service interface name of the corresponding service request is transmitted to the task of the queue-based timing task component for asynchronous execution.
[0079] The communication middleware is built based on the.NET middleware to bridge the two different language systems, which realizes the cross-system and cross-network protocol http / tcp communication middleware, cross-application and cross-language access between heterogeneous systems, and makes the interaction between the two systems more secure and flexible, making the interaction between the systems more secure and reducing the coupling between the systems. The use of.NET language to develop communication middleware not only takes full advantage of the cross-language, cross-platform, security, and support for open Internet standards and protocols of.NET, but also uses its mature components to quickly build interface management software with strong operability.
[0080] The following are the specific steps of building a communication middleware based on.NET components.
[0081] Step 1: Write the communication middleware to receive external service request entry layer file, define the class QuoteApisController in the controller layer to receive external system post request, when receiving external service request, perform logical processing on the data and encapsulate it into a request data packet with a unique request id, then store each request parameter data packet in the redis database through the unique request id as the primary key, and pass the corresponding request service interface name to the task based on the queue BackgroundJob for asynchronous execution.
[0082] Step 2: Write the corresponding background queue scheduling service interface class QuoteJobService that receives the task queue BackgroundJob execution scheduling in the previous step, define the queue method of all business operations in the interface in this class, and call the corresponding interface in the partner application system after implementing the business logic processing in the corresponding method; this class is executed by the task scheduling component BackgroundJob according to the method name to execute the corresponding queue method to complete the corresponding logical function after the controller layer receives the external request or the QuoteApiCallback class receives the response or message notification from the partner application system.
[0083] Step 3: Write the bridge class QuoteApiReqHandler to call the service request interface of the partner application system, which encapsulates the request interface of various business scenarios into a general request encapsulation class through the request tool class; as a bridge class, it not only solves the compatibility problem between different interface services, but also reduces the code coupling degree, facilitating subsequent maintenance and expansion.
[0084] Step 4: Write the bridge class QuoteApiRspHandler to receive the response of the counterpart interface and listen to the pushed message. The response tool class encapsulates the response interface and the event of listening to the message in various business scenarios into a general response listening wrapper class. As a bridge class, it not only solves the compatibility problem between different interface services, but also reduces the coupling degree of the code, facilitating subsequent maintenance and expansion.
[0085] Step 5: Write the communication middleware response callback proxy interface class IQuoteCallbackApis. When the communication middleware receives the response of the counterpart service interface (C++ application) or the message pushed by the counterpart server (C++ application) through step 6 or step 7, the corresponding method in the business logic processing class QuoteJobService is scheduled through the task job scheduling component BackgroundJob through the response tool class in step 4, and then the callback class calls the interface of the calling service system (Java application) in the form of post request. According to the single design pattern, the entire data flow process is completed, which not only ensures the safety of data but also reduces the coupling between codes, facilitating subsequent management, expansion, maintenance, and other operations of software.
[0086] Step 6: Write the interface response and message push event registration class QuoteApiBusinessCallback to listen to the business-related interface response and message push event of the counterpart (C++ application). Through this class, the callback events of the business interface in the counterpart (C++ application) base class are rewritten and listened to. When the response or message event is received, the corresponding method in step 4 is triggered. The aspect programming design pattern is used to execute a series of corresponding business logic operations before and after receiving the event, which is more flexible.
[0087] Step 7: Write the interface event registration class QuoteApiServerCallback to listen to the interface events related to the communication middleware and server. Through this class, some operation responses or events related to the application server in the counterpart (C++ application) base class are rewritten or listened to, such as login authentication, logout, and connection information created with the counterpart (C++ application) server, thereby facilitating real-time tracking of the connection state and communication state of the communication middleware and the counterpart (C++ application) server.
[0088] Step 8: Write the callback event custom class IquoteApiCallbackEvents to customize the events involved in the communication middleware and the counterpart application system. It is used to register event listening and receive the message pushed by the counterpart (C++ application) service. In the system design, the custom event class can be customized according to the business scenario to handle various message events and interface service response callbacks.
[0089] Step 9: Write the unmanaged resource explicit release component class IquoteApiComponent, through which some unmanaged resources of the communication middleware can be manually released in special cases. This class mainly involves the scope of server configuration related file information QuoteApiServerConfiguration, communication middleware context session information SessionContext, communication middleware request sending Api (CCTFtdcQuoteApi), communication middleware request response Api (CCTFtdcQuoteSpi) and the like. When an exception occurs in a process of the communication middleware, the event can be handled through the manual operation of the component.
[0090] Step 10: Write the monitoring class FuturesExtensions to monitor the state of the communication middleware in a visual form. Through this static class, the health status of the front-end server can be monitored in real time through the interface by means of the core tool class HealthChecks of.net. For example, the working state of the data cache server redis, the execution state of the job queue hangfire, the connection state of the protocol tcp, and the execution state of the interface service quote-server.
[0091] Step 11: Write the Hangfire dashboard login identity authentication verification and authorization class BasicAuthAuthorizationFilter. This verification class inherits the core layer component IdashboardAuthorizationFilter of.net core to perform login identity authentication verification and authorization on the interface service request state dashboard tracker Hangfire. This class facilitates the permission control of the instrument component of the interface service request state monitoring in the communication middleware.
[0092] Step 12: Write the related classes BasicAuthAuthorizationUser and BasicAuthAuthorizationFilterOptions for Hangfire dashboard identity authentication and resource permissions. Through these classes, the login authentication function of the Hangfire dashboard tracker for the scheduling situation of all interface service requests or responses and task queues in the communication middleware can be completed in cooperation with the verification and authorization class in step 11.
[0093] Step 13: Write the session definition class SessionContext. Through this class, the session state parameters are defined, including Disconnected, Connected, Authenticated, Login, and the like, to provide convenience for the management of managed resources and server states.
[0094] Step 14: Write the constant definition class Constants, define some request response and message push redis database key value and some constant value of the description in the constant class, used for data transmission in cache access, log information printing and return result description etc.
[0095] Step 15: Write the log printing interface IloggerService, through the class to realize the custom encapsulation of the log interface Ilogger, provide convenience for the log information printing and problem tracking of the business function class in the communication middleware.
[0096] Step 16: Write the data formatting tool class JsonHelper, through the tool class to realize the serialization and deserialization of some interface input and output parameter data, provide convenient conditions for the data format processing in the whole communication middleware.
[0097] Step 17: Write the interface and communication middleware component error information unified prompt tool class ValidateModelAttribute, the class inherits the global filter ActionFilterAttribute class to wrap the agreed return state information after unified processing of various error information, so as to facilitate the calling party to make logical judgment according to the return state information of the interface.
[0098] Step 18: Define the out and in parameter entity package Generated involved in all interface services, define the entity class of each interface input and output parameter data in the package, follow the software design architecture hierarchy, facilitate code maintenance and management.
[0099] Step 19: Write the Hangfire Dashboard interface entrance class Program, through the class to integrate the contents monitored by the whole HangfireDashboard instrument panel, present the job queue execution situation in the communication middleware to the developers in the form of interface, so as to realize the real-time viewing of the communication middleware interface service execution state.
[0100] Step 20: Write the log, login authentication and service address related configuration files respectively for the development, stagting and production three kinds of environment configuration files, including communication middleware real-time state monitoring configuration, log printing level and output path, server connection address, authentication account etc.; save some information in the form of configuration file, make the maintenance more flexible and convenient for hosting.
[0101] Step 21: Write project packaging and related files required for release, where install.bat is used to install the release communication middleware, startup.cs is used to start the communication middleware and initialize the related configuration class, and uninstall.bat is used to uninstall the communication middleware;
[0102] Step 22: Write communication middleware request and receive data packet monitoring file FuturesExtensions, which can monitor Hangfire job task scheduling information in real time through the management interface; this function mainly contains the total queue number, scheduled execution, execution in progress, completed, failed, and various state queue numbers in the waiting state;
[0103] Step 23: Write the auxiliary startup class Bootstrap that controls all interface services in the communication middleware, through which the interface services can be controlled as a whole, and the QuoteApiServer core service component, all services in QuoteApisController can be started or paused, deleted, etc.
[0104] Step 24: After the program test is passed, export the corresponding installation package shgt-trade-futures.exe, deploy the installation package on the server prepared in advance and open the corresponding outbound and inbound strategy, and the external application system can communicate with the communication middleware through the http protocol, and the communication middleware calls the related service interface of the C++ application system through internal logic processing, solving the interaction problem between two different language systems.
[0105] When the application system initiates a call and callback operation, developers can monitor and track service request state information and callback service response information in real time through the Hangfire dashboard, and developers can manually retry failed interface services.
[0106] The Hangfire Dashboard instrument monitoring management layer needs to be further optimized in interface layout and the monitoring range involved, so as to more comprehensively and real-time monitor the working state of the entire communication middleware and facilitate management.
[0107] The method of the present application makes full use of the design patterns and principles of software, and can use design patterns such as adapter pattern and decorator pattern to compatible more language interfaces and prepare for the subsequent expansion and maintenance of software; try to use some mature component libraries in the.NET framework to enhance the efficiency and reliability of the entire system in use.
[0108] Figure 2 A block diagram of a system for cross-language application system communication according to an example embodiment of the present application is shown.
[0109] Figure 3 An interaction diagram showing inter-language application system communication according to an example embodiment of the present application.
[0110] A system for inter-language application system communication, comprising a first language application system 210, a second language application system 220, and a communication middleware 230.
[0111] Communication using the system for inter-language application system communication mainly includes the following processes:
[0112] 1) The front-end application of the external system (the external system can be a Java system or a system in other programming languages) sends an http request to the communication front-end service (i.e., the communication middleware), which is open as a restful service, taking full advantage of the.NET framework's cross-language, cross-platform, security, and support for open internet standards and protocols.
[0113] 2) The request information received in step 1) is logically processed and placed in a job scheduling queue, and the job is completed in an asynchronous manner through the queue; this not only reduces the high concurrency pressure on the server, but also improves the execution performance of the system.
[0114] 3) The job queue in step 2) is interacted with the service end application of the opposite system (here the opposite system is a C++ developed system) one by one through the tcp protocol, and the use of the tcp stateful protocol can guarantee the safety and stability of data transmission.
[0115] 4) The communication middleware receives messages or responses from the opposite system through event listening, and after logical processing, responds to the front-end application of the external system in the form of an http request.
[0116] The execution status of each request received from the external system at each stage can be monitored in real time by the developer through Figure 4 the dashboard.
[0117] Failed requests in step 4) can be traced by feedback information, and manual retry operations can be performed under certain conditions.
[0118] The developer can monitor the working status of each component of the communication middleware in real time through Figure 4 the interface shown in FIG. 5, such as the working status of the data cache server redis, the execution status of the job queue hangfire, the connection status of the protocol tcp, and the execution status of the interface service quote-server. Among them, Figure 4Fig. 5(a) and Fig. 5(b) show interface schematic diagrams of cross-language application system communication according to another example embodiment of the present application.
[0119] The above functions can ensure transparency and stability of a service request in the whole interaction process.
[0120] The present application solves the bottleneck problem of cross-language application system interaction communication, and developers can monitor the information transmission between systems in real time and perform manual intervention operation during communication.
[0121] It should be clearly understood that the present application describes how to form and use specific examples, but the present application is not limited to any details of these examples. Instead, based on the teachings of the disclosure of the present application, these principles can be applied to many other embodiments.
[0122] Those skilled in the art can understand that all or part of the steps of the above embodiments are implemented as computer programs executed by a CPU. When the computer program is executed by the CPU, the program that performs the above functions defined by the above method provided by the present application can be stored in a computer readable storage medium, which can be a read-only memory, a disk or an optical disk, etc.
[0123] In addition, it should be noted that the above figures are only schematic illustrations of the processes included in the method according to the example embodiments of the present application, and are not for limiting purposes. It is easy to understand that the processes shown in the above figures do not indicate or limit the time sequence of these processes. In addition, it is also easy to understand that these processes can be executed synchronously or asynchronously, for example, in multiple modules.
[0124] Through the description of the example embodiments, those skilled in the art can easily understand that the cross-language application system communication method according to the embodiments of the present application has at least one or more of the following advantages.
[0125] According to the example embodiments, by building a bridge between cross-language systems based on.NET, i.e. communication middleware, the interaction between two systems is more secure and flexible; the interaction between systems is more secure and the coupling between systems is reduced.
[0126] Figure 6 Fig. 1 shows a block diagram of an electronic device according to an example embodiment.
[0127] The electronic device 200 according to this implementation of the present application will be described below with reference to Figure 6 Fig. 1. Figure 6 The electronic device 200 shown is merely an example and should not impose any limitation on the functions and scope of use of the embodiments of the present application. The electronic device 200 shown is merely an example and should not impose any limitation on the functions and scope of use of the embodiments of the present application.
[0128] As shown in Figure 6 The electronic device 200 is, in one embodiment, a general purpose computing device in the form of a desktop computer. Components of the electronic device 200 can include, but are not limited to, at least one processing unit 210, at least one storage unit 220, a bus 230 that connects the various system components including the storage unit 220 and the processing unit 210, a display unit 240, and the like.
[0129] The storage unit stores program code that can be executed by the processing unit 210 such that the processing unit 210 performs the methods described in this specification in accordance with the various example embodiments of the present application.
[0130] The storage unit 220 can include a readable medium in the form of volatile storage such as random access memory (RAM) 2201 and / or cache memory 2202, and can further include a non-volatile storage such as read only memory (ROM) 2203.
[0131] The storage unit 220 can also include a program / utility 2204 having a set of program modules 2205 such as an operating system, one or more application programs, other program modules, and program data, each of which can give the electronic device 200 its functionality, at least in part. Each of the operating system, one or more application programs, other program modules, and program data can include an implementation of a networking environment, alone or in combination with another or some combination of these examples.
[0132] The bus 230 can represent one or more of several types of bus structures, including a storage bus or bus controller, a peripheral bus, a graphics bus (e.g., an Accelerated Graphics Port, or AGP bus) and a local bus using any of a variety of bus architectures.
[0133] The electronic device 200 can also communicate with one or more external devices 300 such as a keyboard or pointing device, a Bluetooth device, etc.; one or more devices that enable a user to interact with the electronic device 200; and / or one or more devices that enable the electronic device 200 to communicate with one or more other computing devices. Such communication can be via an input / output (I / O) interface 250. Similarly, the electronic device 200 can communicate with one or more networks, such as a local area network (LAN), a wide area network (WAN), and / or the Internet, via a network adapter 260. The network adapter 260 can communicate with the other components of the electronic device 200 via the bus 230. It should be appreciated that, although not shown, other hardware and / or software components that can be used in conjunction with the electronic device 200 can include, but are not limited to, microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data archival storage systems, etc.
[0134] Those skilled in the art can easily understand that the example embodiments described herein can be implemented by software, or by software in combination with necessary hardware, through the above description of the embodiments. The technical solutions according to the embodiments of the present application can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (which can be a CD-ROM, a U disk, a mobile hard disk, etc.) or a network, and includes a number of instructions to make a computing device (which can be a personal computer, a server, or a network device, etc.) execute the above-mentioned method according to the embodiments of the present application.
[0135] The software product can adopt any combination of one or more readable media. The readable medium can be a readable signal medium or a readable storage medium. The readable storage medium may, for example, be but is not limited to an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or apparatus, or any combination of the above. More specific examples (non-exhaustive list) of the readable storage medium include an electrical connection having one or more wires, a portable disk, 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 disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above.
[0136] The computer readable storage medium can include a data signal carried in the baseband or as a part of a carrier wave propagating through the transmission medium, in which a readable program code is borne. Such a propagated data signal can take on many forms, including but not limited to electro-magnetic, optical, or any suitable combination thereof. The readable storage medium can also be any readable medium that can send, propagate, or transmit a program for use by or in connection with an instruction execution system, apparatus, or device. The program code contained on the readable storage medium can be transmitted using any suitable medium, including but not limited to wireless, wired, optical fiber, RF, etc., or any suitable combination thereof.
[0137] The program code may, for example, be written in any combination of one or more programming languages, including an object oriented programming language such as Java, C++ or the like, and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code may execute entirely on the user's computing device, partly on the user's computing device, as a stand-alone software package, partly on the user's computing device and partly on a remote computing device or entirely on the remote computing device or server. In the latter scenario, the remote computing device can be connected to the user's computing device through any type of network, including a local area network (LAN) or a wide area network (WAN), or the connection can be made to an external computing device, for example, through the Internet using an Internet Service Provider.
[0138] Those skilled in the art can understand that the above-mentioned modules can be distributed in the device according to the description of the embodiment, and can also be changed in one or more devices different from the embodiment. The modules of the above-mentioned embodiment can be combined into one module, or can be further split into multiple sub-modules.
[0139] The exemplary embodiments of this application are specifically shown and described above. It is to be understood that the application is not limited to the detailed construction, arrangements or implementation methods described herein; on the contrary, the application is intended to cover various modifications and equivalent arrangements included within the spirit and scope of the appended claims.
Claims
1. A method for communication between cross-language application systems, used for communication between a first-language application system and a second-language application system, characterized in that, The method includes: Create a communication middleware based on the .NET framework; By combining the components of the communication middleware with the dynamic link library of the first language application system, the .NET framework-based communication middleware can interact and communicate with the first language application system. The second language application system interacts with the communication middleware based on the HTTP protocol to send HTTP requests to the communication middleware. The communication middleware receives the request information, performs logical processing, and puts it into the job scheduling queue, so that the job can be completed asynchronously through the queue. The communication middleware interacts with the first language application system one by one in the job scheduling queue via the TCP protocol; The communication middleware receives messages or responses from the first language application system through event listening. After receiving the messages or responses, it performs logical processing and then responds to the second language application system in the form of an HTTP request. Write the communication middleware response callback proxy interface class. When the communication middleware receives the response from the service interface of the first language application system or the message pushed by the first language application system, it schedules the corresponding method in the business logic processing class through the task scheduling component via the response utility class, and then calls back the interface of the second language application system in the form of a POST request through the callback class.
2. The method according to claim 1, characterized in that, The creation of the communication middleware based on the .NET framework includes: Construct a layered structure for the communication middleware project, which includes a control layer, application service layer, core layer, reference layer, entity definition layer, attribute definition layer, and library file layer; The control layer is the entry point for receiving external requests. The application service layer is used to perform logical processing on the incoming or outgoing data. The core layer includes core utility classes and framework components. The reference layer is used to import header files and core utility classes related to the other party's interface. The entity definition layer is used to define data transmission object entity classes. The attribute definition layer is used to define attribute files related to configuration. The library file layer is used to import dynamic and static library files of the other party's interface.
3. The method according to claim 1, characterized in that, As required, import the relevant dynamic library files that have been compiled by the first language application system and the publicly available header files containing the first language function interface methods. The header files include a first header file, a second header file, and a third header file. The first header file contains the interfaces involved and the definition classes for creating connections. The second header file defines the data types involved in the interfaces. The third header file defines the data structures involved in the interfaces.
4. The method according to claim 2, characterized in that, The creation of the communication middleware based on the .NET framework includes: The core layer components of the communication middleware include a timed task queue processing component and a system health performance monitoring component. The received service requests are processed asynchronously as queued tasks by the timed task component in the timed task queue processing component. The system health performance monitoring component monitors the working status of relevant modules in the communication middleware in real time, including the working status of the application server, the database status, the TCP connection status, and the job queue status.
5. The method according to claim 4, characterized in that, The creation of the communication middleware based on the .NET framework also includes: The core layer component of the communication middleware is constructed for connecting with the first language application system, logging in and authenticating, and performing initialization operations on the communication middleware through the core layer component when the communication middleware restarts.
6. The method according to claim 5, characterized in that, The creation of the communication middleware based on the .NET framework also includes: The control layer file for constructing the communication middleware includes defining a reference control class for receiving external system service requests. Upon receiving an external system service request, the class performs logical processing on the data and encapsulates it into a request data packet with a unique request identifier. Then, each request data packet is stored in the database using the unique request identifier as the primary key. The corresponding service interface name of the service request is then sent to the task of the queue-based scheduled task component for asynchronous execution.
7. The method according to claim 6, characterized in that, The creation of the communication middleware based on the .NET framework also includes: Construct a configuration information class for the communication middleware, which is used to load necessary information into memory when the communication middleware starts; All configuration information in the configuration file can be directly read through the configuration information class. The configuration information includes communication middleware status indicators, job queue, peer server address, account, password, timeout setting, and log printing storage path.
8. The method according to claim 7, characterized in that, The creation of the communication middleware based on the .NET framework also includes: The core layer component reads the relevant configuration information from the configuration information class during loading and performs initialization operations on the communication middleware. The initialization operations include network communication checks with the first language application system, creating a TCP connection, login, authentication, and event registration for interface response callbacks.
9. The method according to claim 8, characterized in that, The creation of the communication middleware based on the .NET framework also includes: A monitoring class for the communication middleware is constructed. The monitoring class is used to monitor the status of the communication middleware in a visual form. The system health performance monitoring component, which is related to the core library files of the .NET framework, is used to implement real-time monitoring of the health status of the communication middleware in a graphical way, including the working status of the data cache server, the execution status of the job queue, the connection status of the TCP protocol, and the execution status of the interface service.
10. The method according to claim 9, characterized in that, The creation of the communication middleware based on the .NET framework also includes: Construct an entry class for the dashboard monitoring interface of the communication middleware. This class integrates the content monitored by the dashboard and displays the execution status of the job queue in the communication middleware in a graphical way, so as to view the execution status of the communication middleware interface service in real time.
11. A system for communication between cross-language application systems, comprising a first-language application system, a second-language application system, and communication middleware, characterized in that, The second language application system sends an HTTP request to the communication middleware; The communication middleware receives the request information, performs logical processing, and puts it into the job scheduling queue, so that the job can be completed asynchronously through the queue. The communication middleware interacts with the first language application system one by one in the job scheduling queue via the TCP protocol; The communication middleware receives messages or responses from the first language application system through event listening. After receiving the messages or responses, it performs logical processing and then responds to the second language application system in the form of an HTTP request. The communication middleware monitors the execution status of the received requests from the second language application system in real time at each stage. The working status of each component of the communication middleware is monitored in real time, including the working status of the data cache server, the execution status of the job queue, the connection status of the TCP protocol, and the execution status of the interface service. Write the communication middleware response callback proxy interface class. When the communication middleware receives the response from the service interface of the first language application system or the message pushed by the first language application system, it schedules the corresponding method in the business logic processing class through the task scheduling component via the response utility class, and then calls back the interface of the second language application system in the form of a POST request through the callback class.
12. A computer program product, comprising a computing program or instructions, characterized in that, When the computer program or instructions are executed by a processor, they implement the method as described in any one of claims 1-10.
Citation Information
Patent Citations
Data processing method and data processing device
CN103577180A
Hyper text transport protocol (http) proxy method and device for message-oriented middleware
CN115118708A