A heterogeneous message conversion method, device and equipment
By parsing the differences between the request message and the entity object model file of the cache list, the entity object model file is automatically updated, solving the problem of heterogeneous message adaptation and achieving efficient adaptation of the rule engine and business continuity.
Patent Information
- Application Number
- CN202411742406.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-29
- Publication Date
- 2025-12-16
- Estimated Expiration
- 2044-11-29
AI Technical Summary
In application scenarios requiring high timeliness and strong continuity, rule engines face challenges in terms of flexibility and efficient adaptation when they need to adapt to heterogeneous messages, especially when interacting with different interface specifications, where the dynamic variability of message fields is difficult to adapt to.
By parsing the differences between the fields of the request message and the entity object model file in the cache list, the entity object model file is automatically updated, and messages in a format supported by the rule engine are generated, thus realizing the conversion and adaptation of heterogeneous messages.
Automatic updates of message fields can be achieved without restarting the project, improving the rule engine's adaptability to heterogeneous messages and ensuring business continuity and seamless dynamic switching.
Smart Images

Figure CN119647414B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of computer, in particular to a heterogeneous message conversion method, device and equipment. BACKGROUND
[0002] The rule engine receives data input, interprets business rules and finally makes corresponding decisions according to business rules. With the advantage of separating business rules from program code, it can quickly respond to frequent market demand and management regulations, reduce application development and operation cost, and is widely used.
[0003] Currently, in the application scene of high timeliness and strong continuity, the flexibility of rules also brings new challenges, especially in the interaction of different interface specifications, it is necessary to meet the efficient adaptation of heterogeneous messages and the dynamic variability of message fields, which puts higher requirements on the adaptation ability of the rule engine platform. SUMMARY
[0004] Therefore, the present application provides a heterogeneous message conversion method, device and equipment, aiming to improve the adaptation ability of the rule engine to heterogeneous messages.
[0005] In a first aspect, the present application provides a heterogeneous message conversion method, comprising:
[0006] parsing the fields of the request message, and if there is a difference between the fields and the parsed fields of the corresponding entity object model file in the cache list, updating the entity object model file according to the fields of the request message;
[0007] calling the latest entity object model file corresponding to the request message from the cache list to generate a first view object, and parsing the request message to assign values to the first view object;
[0008] generating a first message in a first rule engine support format based on the first view object after the assignment.
[0009] Optionally, before parsing the fields of the request message, the method further comprises:
[0010] receiving a request message and performing legality verification on the request message;
[0011] if the request message is verified to be legal, obtaining parameter information of the request message;
[0012] determining whether to switch the rule engine according to the parameter information;
[0013] if the rule engine is switched, performing the parsing of the fields of the request message according to the first rule engine indicated by the parameter information.
[0014] Optionally, the method further comprises:
[0015] If the rule engine is not switched, the request message is sent to the default rule engine for processing, and a response message fed back by the default rule engine is obtained.
[0016] Optionally, the parameter information is a rule engine indicated by an engine selection field;
[0017] The judging whether to switch the rule engine according to the parameter information comprises:
[0018] According to the parameter information, it is judged whether the rule engine indicated by the engine selection field in the request message is a default rule engine.
[0019] Optionally, after the first message in the first rule engine support format is generated based on the first view object after the assignment, the method further comprises:
[0020] The first message is sent to a first rule engine indicated by an engine selection field of the first message, and a response message fed back by the first rule engine is obtained.
[0021] Optionally, the method further comprises:
[0022] If the rule engine is switched, a second view object is generated by calling a latest entity object model file corresponding to the response message, and the response message is assigned to the second view object by parsing; a second message in a format supported by the default rule engine is generated based on the second view object after the assignment, and the second message is sent to an upper-layer business application;
[0023] If the rule engine is not switched, the response message is sent to the upper-layer business application.
[0024] In a first aspect, the application provides a heterogeneous message conversion device, comprising a message conversion unit and an entity updating unit; the message conversion unit and the entity updating unit are in bidirectional communication; the message conversion unit comprises a message converter, a data reader and a cache list, and the entity updating unit comprises a message parser and an entity updater;
[0025] The message parser is configured to parse a request message to obtain a field, and to obtain an entity object model file corresponding to the request message from the cache queue and to parse the obtained field.
[0026] The entity updater is configured to compare the field parsed by the message parser from the request message and the field parsed from the corresponding entity object model file, and if there is a difference in the comparison, to update the corresponding entity object model file in the cache queue according to the field of the request message.
[0027] The data reader is configured to call the latest entity object model file corresponding to the request message from the cache queue;
[0028] The message converter is configured to send the received request message to the message parser, generate a first view object according to the latest entity object model file called by the data reader, assign values to the first view object by parsing the request message, and generate a first message in a first rule engine support format based on the first view object after the assignment.
[0029] Optionally, the device further comprises an engine control unit, the engine control unit is in bidirectional communication with the message converter, and the engine control unit is also in bidirectional communication with the rule engine bottom layer; the engine control unit comprises an engine switcher, an object calculation driver, and a message processor.
[0030] The engine switcher is configured to receive a request message sent by an upper-layer business application, determine whether a rule engine corresponding to an engine selection field in the request message is a default rule engine, send the request message to the message converter if the rule engine corresponding to the engine selection field in the request message is not the default rule engine, and send the request message to the object calculation driver if the rule engine corresponding to the engine selection field in the request message is the default rule engine.
[0031] The object calculation driver is configured to receive the request message sent by the engine switcher and the first message sent by the message converter, and send the received message to the rule engine corresponding to the engine selection field in the message.
[0032] The message processor is configured to filter a response message fed back from the rule engine bottom layer, send the response message to the message converter of the message conversion unit for message conversion to obtain a second message in a format supported by the default rule engine if the rule engine is switched, and send the second message to the upper-layer business application, and send the response message to the upper-layer business application if the rule engine is not switched.
[0033] Optionally, the device further comprises a message delivery unit, the message delivery unit is arranged between the upper-layer business application and the engine control unit, and the message delivery unit comprises a message receiver and a message sender.
[0034] The message receiver is configured to receive a request message sent by an upper-layer business application, perform legality verification on the request message, and send the request message verified as legal to the engine switcher of the engine control unit.
[0035] The message sender is configured to receive a message fed back by the message processor of the engine control unit and send the message to the upper-layer business application.
[0036] In a third aspect, the present application also provides a computer device comprising a memory for storing instructions or codes and a processor for executing the instructions or codes to make the device perform the heterogeneous message conversion method according to any one of the above aspects.
[0037] The present application provides a heterogeneous message conversion method, device and equipment. The method comprises parsing fields of a request message, updating an entity object model file according to the fields of the request message if there is a difference between the fields and parsed fields of the corresponding entity object model file in a cache list, calling the latest entity object model file corresponding to the request message from the cache list to generate a first view object, parsing the request message to assign values to the first view object, and generating a first message in a first rule engine support format based on the first view object after the assignment. In this way, the corresponding entity object model file in the cache list is automatically updated by comparing the difference between the fields of the request file and the corresponding entity object model file, and there is no need to restart the project to add the entity class file corresponding to the message after the field change, thereby solving the problem of dynamic change of message fields and improving the adaptation capability of the rule engine to heterogeneous messages. BRIEF DESCRIPTION OF DRAWINGS
[0038] To make the technical solutions in the embodiments or the prior art clearer, the accompanying drawings needed in the embodiments or the prior art description will be briefly introduced. Obviously, the accompanying drawings in the following description are only some embodiments of the present application, and other accompanying drawings can be obtained by those skilled in the art without any creative effort.
[0039] Figure 1 A flowchart of a heterogeneous message conversion method provided by the method of the embodiments of the present application;
[0040] Figure 2 An application flowchart of a heterogeneous message conversion method provided by the embodiments of the present application;
[0041] Figure 3 A message conversion process diagram provided by the embodiments of the present application;
[0042] Figure 4 A structure diagram of a heterogeneous message conversion device provided by the embodiments of the present application;
[0043] Figure 5 A structure diagram of another heterogeneous message conversion device provided by the embodiments of the present application. DETAILED DESCRIPTION
[0044] Based on the above problems, the application provides a heterogeneous message conversion method, device and equipment, relating to the technical field of computer, which comprises parsing the fields of a request message, updating the entity object model file according to the fields of the request message if there is a difference between the fields and the parsed fields of the corresponding entity object model file, calling the latest entity object model file corresponding to the request message to generate a first view object, and parsing the request message to assign values to the first view object; and generating a first message in the first rule engine support format based on the assigned first view object. The fields in the request message are identified, and when the fields in the request message change, the entity class corresponding to the fields in the request message is set to update the corresponding entity object model file in the cache list. The latest entity object file corresponding to the request message is read from the cache queue using the custom class loader to generate the view object corresponding to the message. In this way, the entity object model file is automatically updated without restarting the project, and the entity class file corresponding to the message after the field change is added, thereby solving the problem of dynamic change of message fields and realizing the conversion of the request message into a message compatible with the rule engine, and improving the adaptation capability of the rule engine to heterogeneous messages.
[0045] In addition, the upper-layer business application and the A rule engine support the same format of message, and the A rule engine is used as the default rule engine. However, the rule calculation takes the rule set as the minimum granularity, and the adaptation capabilities of different engines to the rule set are different. When the B rule engine is more suitable for the message for rule calculation, the request message of the upper-layer business application can be forwarded to the B rule engine for rule calculation by switching the rule set switch state. However, the message in the format supported by the default rule engine needs to be converted into the message in the format supported by the B rule engine, and the calculation result of the B rule engine needs to be converted into the message in the format supported by the upper-layer business application for feedback.
[0046] The application further constructs a heterogeneous message conversion device. First, the entity object model file is automatically updated by the message conversion unit and the entity updating unit to adapt to the dynamic change of the message field and to realize the heterogeneous conversion between the format supported by the upper-layer business application and the format supported by the rule engine compatible with the message. Further, the engine control unit receives the request message, the engine switcher determines whether the message needs to be sent to the message conversion unit for conversion of the heterogeneous message, and the object calculation driver sends the message to the rule engine for processing. The engine control unit receives the response message, and then the message processor determines whether the message needs to be sent to the message conversion unit for conversion into the message format compatible with the upper-layer application. In this way, the heterogeneous message is accurately converted during the dynamic switching of the rule engine, a unified service is provided for the upper-layer business application, the differences caused by the dynamic switching process of the underlying engine are shielded, and the business continuity is ensured.
[0047] In order to enable more detailed understanding of the features and technical contents of the embodiments of the present disclosure, the implementation of the embodiments of the present disclosure is described in detail below, and the attached drawings are only used for reference and do not limit the embodiments of the present disclosure. In the following technical description, in order to facilitate explanation, through multiple details, a sufficient understanding of the disclosed embodiments is provided. However, one or more embodiments can still be implemented without these details. In other cases, in order to simplify the drawings, well-known structures and devices can be simplified.
[0048] The terms "first", "second", and the like in the description and claims of the embodiments of the present disclosure and the above-mentioned drawings are used to distinguish similar objects, and do not necessarily describe a specific order or sequence. It should be understood that the data used in this way can be interchanged under appropriate circumstances, so that the embodiments of the present disclosure described herein can be implemented. In addition, the terms "include" and "have" and any variations thereof are intended to cover non-exclusive inclusion.
[0049] Unless otherwise specified, the term "multiple" means two or more.
[0050] In the embodiments of the present disclosure, the character " / " represents an "or" relationship between the objects before and after it. For example, A / B represents: A or B.
[0051] The term "and / or" is a description of the relationship between the objects, which means that there can be three relationships. For example, A and / or B, which means: A or B, or, A and B, three relationships.
[0052] In order to make the purposes, technical solutions and advantages of the embodiments of the present application more clear, the technical solutions in the embodiments of the present application will be described clearly and completely below in combination with the drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, not all embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative labor are within the scope of protection of the present application.
[0053] Referring to Figure 1 , Figure 1 A flowchart of a heterogeneous message conversion method provided by the embodiments of the present application is shown. The heterogeneous message conversion method comprises:
[0054] S101, parsing the field of the request message, if there is a difference between the field and the parsed field of the corresponding entity object model file in the cache list, then updating the entity object model file according to the field of the request message.
[0055] The cache list is used to store entity object model files, and the entity object model files can be read from the cache queue using a custom class loader. The class loader is an important component of the Java virtual machine, which is used to load classes into memory and dynamically generate Java objects at runtime.
[0056] The fields of the request message are parsed. The entity object model file corresponding to the request message is called from the cache list, and the fields of the entity object model file are parsed. The differences between the fields of the request message and the fields of the entity object model file are compared. When there are differences, the fields of the request message have changed, and the latest rule entity object model file can be generated based on the fields of the request message and the cache list is updated. In this way, the cache list can be automatically updated to better adapt to the dynamic changes of the fields.
[0057] S102, generate a first view object from the latest entity object model file corresponding to the request message in the cache list, and parse the request message to assign values to the first view object.
[0058] The view object is a display layer object, mainly used in the binding operation of front-end data and controls, and exists in the form of key-value pairs.
[0059] S103, generate a first message in the first rule engine support format based on the first view object after the assignment.
[0060] The rule engine is a component embedded in the application program, which separates the business logic from the application code. The rule engine uses a specific syntax to write business rules, receives data input, interprets business rules, and finally makes decisions according to business rules.
[0061] The above steps complete the heterogeneous message conversion from the request message to the first message, where message conversion usually refers to conversion between different communication protocols or data formats. Common messages include JSON (JavaScript) messages, SOAP (Simple Object Access Protocol) messages, HTTP messages, etc.
[0062] The entity object model file in the cache list is updated by step S101 according to the change of the field of the request message before the heterogeneous conversion of the request message. Further, the entity object model file applicable to the request message with the field update is read in step S102, the entity class is loaded into the memory through the class loader, and the attribute is filled and assigned through the parsing of the field of the request message. Further, in step S103, the field of the request message is taken as a carrier of the view object, the class constructor is used to assemble and parse the message according to the message format supported by the first rule engine according to the first rule engine, and the first message is formed. In this way, the entity object model file is automatically updated, the project does not need to be restarted, the entity class file corresponding to the message after the field change is added, the problem of dynamic change of the message field is solved, the request message is converted into the first message adapted to the rule engine, and the adaptation capability of the rule engine to the heterogeneous message is improved.
[0063] In the embodiment of the present application, the steps S101-S103 described above Figure 1 The steps S101-S103 described above also have various possible application implementation manners, which will be introduced below. It should be noted that the implementation manners given in the following introduction are only exemplary and do not represent all implementation manners of the embodiment of the present application.
[0064] Referring to the application flowchart of the heterogeneous message conversion method shown in FIG. 1. Figure 2 The request message sent by the upper-layer business application can be adapted to the corresponding rule engine for processing and the processing result is fed back to the upper-layer business application.
[0065] S201, receiving a request message and performing legality verification on the request message.
[0066] S202, if the request message is verified to be legal, obtaining parameter information of the request message.
[0067] Of course, if the request message is not verified to be legal, the subsequent process is ended.
[0068] In a possible implementation manner, the parameter information can be a rule engine indicated by the engine selection field.
[0069] S203, determining whether to switch the rule engine according to the parameter information.
[0070] For example, when the upper-layer business application and the A rule engine support the same format of message, the A rule engine is the default rule engine, but the rule calculation takes the rule set as the minimum granularity, and different engines have different adaptation capabilities to the rule set. When the B rule engine is more suitable for the current message for rule calculation, the default rule engine can be switched to the B rule engine for calculation and processing.
[0071] In a possible implementation, the parameter information is a rule engine indicated by an engine selection field, and the determining whether to switch the rule engine comprises: determining whether the rule engine indicated by the engine selection field in the request message is a default rule engine. When the rule engine indicated by the engine selection field in the request message is not the default rule engine, the rule engine is switched; and when the rule engine indicated by the engine selection field in the request message is the default rule engine, the rule engine is not switched, and the default rule engine is continued to be used.
[0072] S204, if the rule engine is switched, performing steps S101-S103 according to the first rule engine indicated by the parameter information to obtain a first message in a format supported by the first rule engine; and if the rule engine is not switched, directly performing step S205.
[0073] For example, when the default rule engine (A rule engine) is not suitable for performing the calculation processing on the request message, the first rule engine (B rule engine) indicated by the request message can be switched to perform the processing, but before the processing is performed by using the first rule engine (B rule engine), steps S101-S103 need to be performed to convert the request message into a first message in a format supported by the first rule engine (B rule engine).
[0074] S205, sending the first message to a first rule engine indicated by an engine selection field of the first message to obtain a response message fed back by the first rule engine; or, in the case where the rule engine is not switched, sending the request message to the default rule engine for processing to obtain a response message fed back by the default rule engine.
[0075] When the request message is directly adapted to the current default rule engine (A rule engine), steps S101-S103 can not be performed, and the request message can be directly sent to the default rule engine for processing to obtain a response message fed back by the default rule engine.
[0076] S206, determining whether the rule engine is switched.
[0077] S207, if the rule engine is switched, generating a second view object by calling a latest entity object model file corresponding to the response message, and parsing the response message to assign values to the second view object; and generating a second message in a format supported by the default rule engine based on the second view object after the assignment. If the rule engine is switched, step S207 is directly performed.
[0078] The response message is converted into a second message in a format supported by the default rule engine (an upper-layer business application).
[0079] S208, sending the second message to the upper-layer service application; or sending the response message to the upper-layer service application without switching the rule engine.
[0080] The steps S201-S208 achieve that the request message sent by the upper-layer service application can be adapted to the corresponding rule engine for processing and the processing result is fed back to the upper-layer service application.
[0081] Referring to Figure 3 The message conversion process diagram shown in the figure achieves the message conversion adapting to different rule engines, thereby achieving the dynamic switching of the rule engine without sensing.
[0082] For the steps S204 and S207 in the steps S201-S208, the message conversion is performed twice. The step S204 performs the first message conversion, which occurs when the request message is converted into the first message in the format supported by the B rule engine which is a non-default rule engine. In this process, first, the A rule engine access layer of the default rule engine is taken as the destination and receives the request message of the upper-layer service application. First, the latest entity object model file corresponding to the request message is loaded into the memory from the cache queue by using the class loader. Second, the view object is generated using the entity object model. Then, the fields of the request message are parsed and assigned to the view object. Finally, the view object after the assignment is used to generate the streaming message (the first message) adapting to the B rule engine and the first message is forwarded to the B rule engine.
[0083] The step S207 performs the second message conversion, which occurs when the calculation result of the B rule engine is returned to the upper-layer service application. The A rule engine access layer is taken as the source. First, the entity class view object is generated by loading the corresponding entity object model file from the cache queue by using the class loader. Second, the field content of the response message is assigned to the view object. Then, the view object after the assignment is converted into the second message in the format supported by the A rule engine, thereby completing the conversion of the message between the B rule engine and the A rule engine. Finally, the second message is returned to the upper-layer service application.
[0084] Based on the above embodiment, the application achieves the accurate conversion of the heterogeneous message in the dynamic switching process of the rule engine, provides a unified service for the upper-layer service application, shields the difference caused by the dynamic switching process of the bottom rule engine, achieves the switching without sensing and guarantees the service continuity.
[0085] The above is some specific implementation manners of the heterogeneous message conversion method provided by the embodiment of the application. Based on this, the application further provides a corresponding device. The device provided by the embodiment of the application will be introduced from the functional modularization.
[0086] Referring to Figure 4A structure diagram of a heterogeneous message conversion device is shown, and the device comprises a message conversion unit and an entity updating unit.
[0087] The message conversion unit and the entity updating unit communicate with each other; the message conversion unit comprises a message converter, a data reader and a cache list, and the entity updating unit comprises a message parser and an entity updater.
[0088] The message parser is configured to parse a field of a request message, acquire an entity object model file corresponding to the request message from the cache queue, and parse the acquired field.
[0089] The entity updater is configured to compare the field of the request message parsed by the message parser and a field of the corresponding entity object model file, and if there is a difference, update the corresponding entity object model file in the cache queue according to the field of the request message.
[0090] The data reader is configured to call the latest entity object model file corresponding to the request message from the cache queue.
[0091] The message converter is configured to send a received request message to the message parser, generate a first view object according to the latest entity object model file called by the data reader, assign a value to the first view object by parsing the request message, and generate a first message in a first rule engine support format based on the first view object after the assignment.
[0092] Based on Figure 4 The device shown can automatically update the entity object model file through the message conversion unit and the entity updating unit, adapt to dynamic changes in the fields of the message, and also enable heterogeneous conversion between the format supported by the upper-layer business application and the format supported by the rule engine adapted to the message.
[0093] In a possible implementation manner, referring to Figure 5 A structure diagram of another heterogeneous message conversion device is shown, and the device is based on Figure 4 The device shown further comprises an engine control unit; the engine control unit communicates with the message conversion unit, and the engine control unit also communicates with a rule engine bottom layer; the engine control unit comprises an engine switcher, an object calculation driver and a message processor.
[0094] The engine switcher is configured to receive a request message sent by an upper-layer service application, and acquire parameter information of the request message; determine whether to switch a rule engine according to the parameter information; if the rule engine is switched, execute field analysis of the request message according to a first rule engine indicated by the parameter information; and if the rule engine is not switched, send the request message to the object computing driver.
[0095] The object computing driver is configured to receive the request message sent by the engine switcher and the first message sent by the message converter, and send the received message to a rule engine corresponding to an engine selection field in the message.
[0096] The message processor is configured to filter a response message fed back from the rule engine bottom layer; if the rule engine is switched, send the response message to the message converter of the message conversion unit for message conversion to obtain a second message in a format supported by a default rule engine, and send the second message to the upper-layer service application; and if the rule engine is not switched, send the response message to the upper-layer service application.
[0097] Rule calculation takes a rule set as a minimum granularity, different engines have different adaptation capabilities for the rule set, when the B rule engine is more suitable for rule calculation of the message, a service side (providing a rule engine calculation service) can forward a request message of a consumption side (needing rule engine calculation) to the B rule engine for rule calculation by switching a rule set switch state, and return a calculation result of the B rule engine to the consumption side, so that the switching process is not sensed by the consumption side. The switching of the rule engine is to set the rule set switch in a rule engine access layer, under normal circumstances, the switch points to a default rule engine (A rule engine) to call the A rule engine for calculation, and when the B rule engine type is more suitable for rule calculation, the switch switches to the B rule engine to call the B rule engine for calculation.
[0098] Optionally, the engine switcher is further configured to receive a request message sent by an upper-layer service application, and determine whether a rule engine corresponding to an engine selection field in the request message is a default rule engine; if the rule engine corresponding to the engine selection field in the request message is not the default rule engine, send the request message to the message converter; and if the rule engine corresponding to the engine selection field in the request message is the default rule engine, send the request message to the object computing driver.
[0099] Optionally, referring to Figure 5 The apparatus further includes a message delivery unit, which is arranged between the upper-layer service application and the engine control unit, and includes a message receiver and a message sender.
[0100] The message receiver is configured to receive a request message sent by an upper-layer service application, and perform legality verification on the request message, and send the request message that passes the verification to an engine switcher of the engine control unit; and the message transmitter is configured to receive a message fed back by a message processor of the engine control unit and send the message to the upper-layer service application.
[0101] Based on the above device, the operation flow of the device can be as follows:
[0102] Step one: the message receiver receives a request message sent by an upper-layer application, and performs legality verification on the request message; if the request message is not legal, the subsequent flow is ended; if the request message passes the verification, the request message is sent to an engine switcher of the engine control unit.
[0103] Step two: the engine switcher judges whether a rule engine indicated by an engine selection field in the request message is a default rule engine; if yes, the message is sent to an object computing driver; otherwise, the request message is sent to a message converter of a message conversion unit.
[0104] Step three: the message converter sends the request message to an entity updating unit; when a field changes, the entity updating unit generates an entity object model file of the latest rule and stores the file in a cache queue of the message conversion unit.
[0105] Step four: the message converter completes dynamic conversion of heterogeneous messages by using a data reader and the cache queue, and sends a first message converted to the object computing driver.
[0106] Step five: the object computing driver selects a corresponding rule engine according to an engine selection field in the first message to perform rule calculation.
[0107] Step six: a message processor filters a response message fed back by the rule engine; if the rule engine is switched, the response message is sent to the message converter of the message conversion unit to be converted to a second message in a format supported by the default rule engine, and the second message is sent to the upper-layer service application; if the rule engine is not switched, the response message is sent to the upper-layer service application.
[0108] Step seven: it is judged whether the called rule engine is the default rule engine; if yes, a return message is sent to the message transmitter; otherwise, the return message is sent to the message converter, the return message is converted again, and a second return message converted is sent to the message processor and then to the message transmitter.
[0109] Step eight: the message transmitter sends a message recognizable by the upper-layer service application to the upper-layer application.
[0110] Based on Figure 5The device shown realizes automatic updating of entity object model files through a message conversion unit and an entity updating unit, is adapted to dynamic changes of message fields, and can also realize heterogeneous conversion between a format supported by a rule engine adapted to message and a format supported by an upper-layer business application. Further, after receiving a request message, an engine controller determines whether the message needs to be sent to the message conversion unit for conversion of heterogeneous messages, and sends the message to the rule engine for processing through an object calculation driver. After receiving a response message, the engine controller then determines whether the message needs to be sent to the message conversion unit for conversion into a message format adapted to the upper-layer application. In this way, accurate conversion of heterogeneous messages in the dynamic switching process of the rule engine provides unified services for the upper-layer business application, shields differences caused by the dynamic switching process of the underlying engine, and guarantees business continuity.
[0111] The embodiments of the present application further provide a corresponding device and a computer storage medium for implementing the scheme provided by the embodiments of the present application.
[0112] The device includes a memory and a processor, the memory is used to store instructions or codes, and the processor is used to execute the instructions or codes to enable the device to execute the heterogeneous message conversion method described in any embodiment of the present application.
[0113] The computer storage medium stores codes, and when the codes are executed, a device executing the codes implements the heterogeneous message conversion method described in any embodiment of the present application.
[0114] The "first" and "second" in the names mentioned in the embodiments of the present application are only used for name identification, and do not represent the first and second in order.
[0115] From the above description of the embodiments, those skilled in the art can clearly understand that all or part of the steps in the above-mentioned embodiment methods can be implemented by means of software plus a general hardware platform. Based on such understanding, the technical solutions of the present application can be embodied in the form of a software product. The computer software product can be stored in a storage medium, such as a read-only memory (English: read-only memory, ROM) / RAM, a magnetic disk, an optical disk, etc., and includes a number of instructions for causing a computer device (which can be a personal computer, a server, or a network communication device such as a router) to execute the methods described in the various embodiments or some parts of the embodiments of the present application.
[0116] The various embodiments described in this specification are intended to be exemplary only. The same features and aspects of the various embodiments can be combined with each other, unless expressly stated otherwise. In particular, the device embodiments are described relatively briefly, as they are substantially similar to the method embodiments. The skilled person can select some or all of the modules described in order to achieve the object of the embodiments. The skilled person can understand and implement the embodiments without inventive labor.
[0117] The above only describes exemplary embodiments of the present application, and is not intended to limit the protection scope of the present application.
Claims
1. A heterogeneous message conversion method, characterized by, The method comprises the following steps: receiving a request message and performing legality verification on the request message; if the request message is verified to be legal, obtaining parameter information of the request message; determining whether to switch a rule engine according to the parameter information; if the rule engine is not switched, sending the request message to a default rule engine for processing to obtain a response message fed back by the default rule engine; if the rule engine is switched, performing field analysis on the request message according to a first rule engine indicated by the parameter information, updating an entity object model file according to the fields of the request message if there is a difference between the fields and analysis fields of a corresponding entity object model file in a cache list, calling a latest entity object model file corresponding to the request message from the cache list to generate a first view object, and assigning values to the first view object by analyzing the request message; generating a first message in a first rule engine support format based on the first view object after the assignment; sending the first message to a first rule engine indicated by an engine selection field of the first message to obtain a response message fed back by the first rule engine; the method further comprises the following steps: if the rule engine is switched, calling a latest entity object model file corresponding to the response message to generate a second view object, assigning values to the second view object by analyzing the response message, generating a second message in a format supported by the default rule engine based on the second view object after the assignment, and sending the second message to an upper-layer business application; if the rule engine is not switched, sending the response message to the upper-layer business application.
2. The method of claim 1, wherein, The parameter information is a rule engine indicated by an engine selection field; the step of determining whether to switch the rule engine according to the parameter information comprises the following step: determining whether the rule engine indicated by the engine selection field in the request message is a default rule engine according to the parameter information.
3. A heterogeneous message conversion apparatus, characterized by, The method comprises the following steps: a message conversion unit and an entity updating unit; the message conversion unit and the entity updating unit are in bidirectional communication; the message conversion unit comprises a message converter, a data reader and a cache list, and the entity updating unit comprises a message parser and an entity updater; the message parser is configured to analyze a request message to obtain fields, and to obtain an entity object model file corresponding to the request message from the cache list and analyze the obtained fields; the entity updater is configured to compare the fields of the request message analyzed by the message parser with fields of the corresponding entity object model file, and to update the corresponding entity object model file in the cache list according to the fields of the request message if there is a difference in the comparison; the data reader is configured to call a latest entity object model file corresponding to the request message from the cache list; the message converter is configured to send the received request message to the message parser; a first view object is generated based on the latest entity object model file called by the data reader, and values are assigned to the first view object by analyzing the request message; a first message in a first rule engine support format is generated based on the first view object after the assignment; and the first message is sent to a first rule engine indicated by an engine selection field of the first message to obtain a response message fed back by the first rule engine. The device further comprises an engine control unit, which is in bidirectional communication with the message conversion unit and further in bidirectional communication with the rule engine bottom layer; the engine control unit comprises an engine switcher, an object calculation driver and a message processor; The engine switcher is configured to receive a request message sent by the upper-layer service application, and determine whether a rule engine corresponding to an engine selection field in the request message is a default rule engine; if the rule engine corresponding to the engine selection field in the request message is not the default rule engine, the request message is sent to the message converter; if the rule engine corresponding to the engine selection field in the request message is the default rule engine, the request message is sent to the object calculation driver; The object calculation driver is configured to receive the request message sent by the engine switcher and the first message sent by the message converter, and send the received message to the rule engine corresponding to the engine selection field in the message; The message processor is configured to filter a response message fed back from the rule engine bottom layer; if the rule engine is switched, the response message is sent to the message converter of the message conversion unit for message conversion to obtain a second message in a format supported by the default rule engine, and the second message is sent to the upper-layer service application; if the rule engine is not switched, the response message is sent to the upper-layer service application; The device further comprises a message delivery unit, which is arranged between the upper-layer service application and the engine control unit, and comprises a message receiver and a message sender; The message receiver is configured to receive a request message sent by the upper-layer service application, and perform legality verification on the request message; the request message verified as legal is sent to the engine switcher of the engine control unit; The message sender is configured to receive a message fed back by the message processor of the engine control unit and send the message to the upper-layer service application.
4. A computer device comprising a memory and a processor, characterized in that, The memory is configured to store instructions or codes, and the processor is configured to execute the instructions or codes, so that the device performs the heterogeneous message conversion method of any one of claims 1-2.
Citation Information
Patent Citations
Message conversion method and device
CN113268955A
Rule engine-oriented middleware adaptation device, configuration method and matching method
CN117632539A