CN110069514B - Message processing method and device - Google Patents

Message processing method and device Download PDF

Info

Publication number
CN110069514B
CN110069514B CN201710982048.0A CN201710982048A CN110069514B CN 110069514 B CN110069514 B CN 110069514B CN 201710982048 A CN201710982048 A CN 201710982048A CN 110069514 B CN110069514 B CN 110069514B
Authority
CN
China
Prior art keywords
message
formula
execution result
message processing
hash table
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201710982048.0A
Other languages
Chinese (zh)
Other versions
CN110069514A (en
Inventor
田野
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Jingdong Century Trading Co Ltd
Beijing Jingdong Shangke Information Technology Co Ltd
Original Assignee
Beijing Jingdong Century Trading Co Ltd
Beijing Jingdong Shangke Information Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Jingdong Century Trading Co Ltd, Beijing Jingdong Shangke Information Technology Co Ltd filed Critical Beijing Jingdong Century Trading Co Ltd
Priority to CN201710982048.0A priority Critical patent/CN110069514B/en
Publication of CN110069514A publication Critical patent/CN110069514A/en
Application granted granted Critical
Publication of CN110069514B publication Critical patent/CN110069514B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/22Indexing; Data structures therefor; Storage structures
    • G06F16/2228Indexing structures
    • G06F16/2255Hash tables
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/24Querying
    • G06F16/242Query formulation
    • G06F16/2433Query languages
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/24Querying
    • G06F16/245Query processing
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/90Details of database functions independent of the retrieved data types
    • G06F16/903Querying
    • G06F16/90335Query processing
    • G06F16/90344Query processing by using string matching techniques
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/448Execution paradigms, e.g. implementations of programming paradigms
    • G06F9/4488Object-oriented
    • G06F9/449Object-oriented method invocation or resolution

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Databases & Information Systems (AREA)
  • Software Systems (AREA)
  • Data Mining & Analysis (AREA)
  • Computational Linguistics (AREA)
  • Mathematical Physics (AREA)
  • Devices For Executing Special Programs (AREA)
  • Information Transfer Between Computers (AREA)

Abstract

The application discloses a message processing method and device. One embodiment of the method comprises: receiving a message to be processed comprising a message topic, a message key and a message value; querying a database associated with the message topic; acquiring a preset processing flow associated with a message theme, wherein the processing flow corresponds to at least one message processing formula and is used for processing a message by using the at least one message processing formula, a message key and a message value; executing at least one message processing formula based on the processing flow, the message key and the message value to obtain an execution result; and executing database operation on the inquired database according to the execution result. This embodiment reduces manual operations and thus increases the efficiency of message processing.

Description

Message processing method and device
Technical Field
The present application relates to the field of computer technologies, and in particular, to a method and an apparatus for processing a message.
Background
In the existing report background logic development, if the processing of the message is involved, the message is firstly accessed, then the code is written according to the accessed message content to process the message, and finally the processed message is inserted or updated into a MySQL (a general relational database management system) database or an Elasticisarch (a general search server) to complete the development of the business logic.
At present, reports are mainly developed and called manually by developers, and then are debugged and corrected repeatedly, so that the message processing efficiency is low.
Disclosure of Invention
An object of the embodiments of the present application is to provide an improved message processing method and apparatus, so as to solve the technical problems mentioned in the above background.
In a first aspect, an embodiment of the present application provides a message processing method, where the method includes: receiving a message to be processed comprising a message topic, a message key and a message value; querying a database associated with the message topic; acquiring a preset processing flow associated with a message theme, wherein the processing flow corresponds to at least one message processing formula and is used for processing a message by using the at least one message processing formula, a message key and a message value; executing at least one message processing formula based on the processing flow, the message key and the message value to obtain an execution result; and executing database operation on the inquired database according to the execution result.
In some embodiments, after receiving a pending message comprising a message topic, a message key, and a message value, the method further comprises: analyzing a message theme and at least one message key value pair of the message by using a preset regular expression; for each message key value pair in at least one message key value pair, separating a message key and a message value from the message key value pair, combining a message theme and the message key in the message key value pair into a formula morpheme according to a preset format, and then generating a first hash table according to the formula morpheme and the message value in the message key value pair.
In some embodiments, before executing the at least one message processing formula to obtain the execution result, the method further comprises: determining a formula type of at least one message processing formula, wherein the formula type comprises at least one of: function type, assignment type and four operation types; and generating a second hash table according to the determined formula type and at least one message processing formula.
In some embodiments, executing the at least one message processing formula results in an execution result, comprising: for each message processing formula in the second hash table, if the formula type of the message processing formula is the four-rule operation type, converting the message processing formula into a suffix expression, obtaining an execution result by using the suffix expression, and storing the execution result in the first hash table.
In some embodiments, executing the at least one message processing formula results in an execution result, comprising: and for each message processing formula in the second hash table, if the formula type of the message processing formula is the function type, obtaining an execution result by using a java reflection method, and storing the execution result into the first hash table.
In some embodiments, the at least one message processing formula comprises a function name, an input parameter, and an output parameter; and obtaining an execution result by using a java reflection method, wherein the execution result comprises the following steps: instantiating a class corresponding to the function name by using a java reflection method; and calling a class execution method based on the input parameters and the message values corresponding to the morphemes of the formulas in the first hash table, outputting an execution result to the output parameters, and storing the output parameters in the first hash table.
In some embodiments, executing the at least one message processing formula results in an execution result, comprising: and for each message processing formula in the second hash table, if the formula type of the message processing formula is the assignment type, taking the calculation result on one side of the message processing formula as an execution result, and storing the execution result in the first hash table.
In some embodiments, performing the database operation on the queried database according to the execution result includes: acquiring a database interaction formula associated with a processing flow; executing a database interaction formula by using a java reflection method to realize at least one of the following operations: add, modify, delete, query.
In a second aspect, an embodiment of the present application provides a message processing apparatus, including: the receiving unit is used for receiving the message to be processed, which comprises a message theme, a message key and a message value; the query unit is used for querying a database associated with the message subject; the message processing device comprises an acquisition unit, a processing unit and a processing unit, wherein the acquisition unit is used for acquiring a preset processing flow associated with a message theme, the processing flow corresponds to at least one message processing formula and is used for processing a message by using the at least one message processing formula, a message key and a message value; the execution unit is used for executing at least one message processing formula based on the processing flow, the message key and the message value to obtain an execution result; and the operation unit is used for executing database operation on the inquired database according to the execution result.
In some embodiments, the apparatus further comprises: the message analysis unit is used for analyzing the message theme and at least one message key value pair of the message by utilizing a preset regular expression after receiving the message to be processed comprising the message theme, the message key and the message value; the first generating unit is used for separating a message key and a message value from at least one message key value pair for each message key value pair in the message key value pairs, combining a message theme and the message key in the message key value pair into a formula morpheme according to a preset format, and then generating a first hash table according to the formula morpheme and the message value in the message key value pair.
In some embodiments, the apparatus further comprises: the formula analysis unit is used for determining a formula type of the at least one message processing formula before executing the at least one message processing formula to obtain an execution result, wherein the formula type comprises at least one of the following items: function type, assignment type and four operation types; and the second generating unit is used for generating a second hash table according to the determined formula type and at least one message processing formula.
In some embodiments, the execution unit is further to: for each message processing formula in the second hash table, if the formula type of the message processing formula is the four-rule operation type, converting the message processing formula into a suffix expression, obtaining an execution result by using the suffix expression, and storing the execution result in the first hash table.
In some embodiments, the execution unit is further to: and for each message processing formula in the second hash table, if the formula type of the message processing formula is the function type, obtaining an execution result by using a java reflection method, and storing the execution result into the first hash table.
In some embodiments, the at least one message processing formula comprises a function name, an input parameter, and an output parameter; and the execution unit is further to: instantiating a class corresponding to the function name by using a java reflection method; and calling an execution device of the class based on the input parameters and the message values corresponding to the morphemes of the formulas in the first hash table, outputting the execution result to the output parameters, and storing the output parameters in the first hash table.
In some embodiments, the execution unit is further to: and for each message processing formula in the second hash table, if the formula type of the message processing formula is the assignment type, taking the calculation result on one side of the message processing formula as an execution result, and storing the execution result in the first hash table.
In some embodiments, the operation unit is further configured to: acquiring a database interaction formula associated with a processing flow; executing a database interaction formula by using a java reflection method to realize at least one of the following operations: add, modify, delete, query.
In a third aspect, an embodiment of the present application provides an apparatus, including: one or more processors; storage means for storing one or more programs; when executed by one or more processors, cause the one or more processors to implement a method as in any one of the first aspects.
In a fourth aspect, the present application provides a computer-readable storage medium, on which a computer program is stored, where the computer program is executed by a processor to implement the method according to any one of the first aspect.
According to the message processing method and device provided by the embodiment of the application, the associated database and the associated processing flow are inquired through the message theme in the message to be processed, the message is processed by executing at least one message processing formula corresponding to the processing flow, and the database is operated according to the execution result. Therefore, manual operation is reduced, and the message processing efficiency is improved.
Drawings
Other features, objects and advantages of the present application will become more apparent upon reading of the following detailed description of non-limiting embodiments thereof, made with reference to the accompanying drawings in which:
FIG. 1 is an exemplary system architecture diagram in which the present application may be applied;
FIG. 2 is a flow diagram for one embodiment of a message processing method according to the present application;
FIG. 3 is a schematic diagram of an application scenario of a message processing method according to the present application;
FIG. 4 is a flow diagram of yet another embodiment of a message processing method according to the present application;
FIG. 5 is a schematic block diagram of one embodiment of a message processing apparatus according to the present application;
fig. 6 is a schematic structural diagram of a computer system suitable for implementing the terminal device or the server according to the embodiment of the present application.
Detailed Description
The present application will be described in further detail with reference to the following drawings and examples. It is to be understood that the specific embodiments described herein are merely illustrative of the relevant invention and not restrictive of the invention. It should be noted that, for convenience of description, only the portions related to the related invention are shown in the drawings.
It should be noted that the embodiments and features of the embodiments in the present application may be combined with each other without conflict. The present application will be described in detail below with reference to the embodiments with reference to the attached drawings.
The present application will be described in further detail with reference to the following drawings and examples. It is to be understood that the specific embodiments described herein are merely illustrative of the relevant invention and not restrictive of the invention. It should be noted that, for convenience of description, only the portions related to the related invention are shown in the drawings.
It should be noted that the embodiments and features of the embodiments in the present application may be combined with each other without conflict. The present application will be described in detail below with reference to the embodiments with reference to the attached drawings.
Fig. 1 illustrates an exemplary system architecture 100 to which embodiments of the message processing method or message processing apparatus of the present application may be applied.
As shown in fig. 1, the system architecture 100 may include terminal devices 101, 102, 103, a network 104, and a server 105. The network 104 serves as a medium for providing communication links between the terminal devices 101, 102, 103 and the server 105. Network 104 may include various connection types, such as wired, wireless communication links, or fiber optic cables, to name a few.
The user may use the terminal devices 101, 102, 103 to interact with the server 105 via the network 104 to receive or send messages or the like. The terminal devices 101, 102, 103 may have various communication client applications installed thereon, such as a report application, a web browser application, a shopping application, a search application, an instant messaging tool, a mailbox client, social platform software, and the like.
The terminal devices 101, 102, 103 may be various electronic devices having display screens and supporting report browsing, including but not limited to smart phones, tablet computers, e-book readers, MP3 players (Moving Picture Experts Group Audio Layer III, mpeg compression standard Audio Layer 3), MP4 players (Moving Picture Experts Group Audio Layer IV, mpeg compression standard Audio Layer 4), laptop portable computers, desktop computers, and the like.
The server 105 may be a server providing various services, such as a background reporting server providing support for reports displayed on the terminal devices 101, 102, 103. The background report server can analyze and process the received data such as the message processing request and feed back the processing result (such as report data) to the terminal device.
It should be noted that the message processing method provided in the embodiment of the present application is generally executed by the server 105, and accordingly, the message processing apparatus is generally disposed in the server 105. Optionally, the message processing method may also be executed by the terminal devices 101, 102, 103, and accordingly, the message processing apparatus may also be provided in the terminal devices 101, 102, 103.
It should be understood that the number of terminal devices, networks, and servers in fig. 1 is merely illustrative. There may be any number of terminal devices, networks, and servers, as desired for implementation.
With continued reference to FIG. 2, a flow 200 of one embodiment of a message processing method according to the present application is shown. The message processing method comprises the following steps:
step 201, receiving a message to be processed including a message topic, a message key and a message value.
In this embodiment, an electronic device (for example, a server shown in fig. 1) on which the message processing method operates may receive a message to be processed, which includes a message topic, a message key, and a message value, from a terminal with which a user browses a report through a wired connection manner or a wireless connection manner. In the reporting system, each message is a standard JSON (JavaScript Object Notation) string. Each message includes three parts, a message topic, a message key (key), and a message value (value).
Message subject: the source of the message, where the alias may be customized.
Message key: the name of the message key-value pair.
Message value: the value of the message key-value pair.
Examples are: a message from the fund _ pay is as follows:
{"stationCode":"11","deliveryErp":"22"}
the topics of this message are: fund _ pay, which may be given the following individual names: FUNDPAY.
The message key is the key of each comma-separated key-value pair, such as: "stationCode", "deliveryErp".
The message value is the value of each comma-separated key-value pair, such as: "11","22".
In some optional implementations of this embodiment, after receiving the message to be processed including the message topic, the message key, and the message value, the method further includes: analyzing a message theme and at least one message key value pair of the message by using a preset regular expression; for each message key value pair in at least one message key value pair, separating a message key and a message value from the message key value pair, combining a message theme and the message key in the message key value pair into a formula morpheme according to a preset format, and then generating a first hash table according to the formula morpheme and the message value in the message key value pair.
Wherein the formula morpheme is the smallest word sequence meaningful in the message processing formula. The formula morpheme is the meaningful minimum word sequence in the message processing formula and is the minimum base point for carrying out logic operation, and the formula morpheme is used for carrying out the increasing, deleting, modifying and checking operation. For example, the message language is converted into a computer-recognized language without changing the semantics according to a predetermined message parsing rule, wherein the message parsing rule must recognize the smallest word in the message processing formula, where the word is the message subject, the message key, and the message value listed in the message logic composition, and then "the message subject [ message key ]" is a meaningful word sequence in the message processing formula, which is referred to as a formula morpheme, for example: FUNDPAY [ stable code ], FUNDPAY [ DeliveryErp ]. For example, each message is read, and each key-value pair in the message is obtained by using a regular expression, so that the message key and the message value become units in an array. Separating each array into arrays again by using colon numbers, separating keys and values, and processing key adding message themes into formula morphemes in the following format: and a message subject [ message key ], putting each number component of processed formula morphemes and values in a first hash table, wherein each key value pair key is as follows: FUNDPAY [ tempStationCode ], value is as follows: 112.
at step 202, a database associated with the subject of the message is queried.
In this embodiment, a corresponding relationship between a message topic and a database is preset, a destination database of a message may be determined by the message topic in the message, and the destination database may further include information such as tables and fields in the destination database.
Step 203, acquiring a preset processing flow associated with the message topic.
In this embodiment, the corresponding relationship between the message topic and the processing flow is preset, and which processing flows are required for processing the message can be determined according to the message topic. The processing flow corresponds to at least one message processing formula and is used for processing the message by using the at least one message processing formula, the message key and the message value. The process flow indicates which steps need to be performed and the order of execution of the steps, each step being implemented by at least one message processing formula. The message processing formula can be viewed as a function and the message keys and message values can be viewed as input parameters to the function. At least one message processing formula can be edited according to the customization of the processing flow, as shown in table 1 below, wherein the sequence number is the execution sequence of the message processing formula:
Figure BDA0001439684740000081
TABLE 1
For example, the message processing formula may include 6 types of addition, subtraction, multiplication, division, assignment, function, and so on. According to the preset formula analysis rule, on the premise of not changing the semantic meaning, the message processing formula is converted into the language recognized by the computer, the analysis rules of various operations are respectively defined below, and the message processing formula is simply called as a formula below.
1) Addition ("+") operation rule
The addition operation of the formula is compared with the addition in the basic four fundamental operations, but terms on two sides become morphemes of the formula, and the basic rule still conforms to the addition in the four fundamental operations, such as: FUNDPAY [ statinCode ] + FUNDPAY [ deviveryErp ] corresponds to the sum of the value of statinCode 11 and the value of deviveryErp 22 in the message, as follows: 11+22.
2) Subtraction ("-") operation rule
Comparing the subtraction operation of the formula with the subtraction in the basic four fundamental operations, except that two side terms become the morphemes of the formula, the basic rule still conforms to the subtraction in the four fundamental operations, and FUNDPAY [ state code ] -FUNDPAY [ deviveryErp ] is equivalent to the subtraction of the value 11 of state code and the value 22 of deviveryErp in the message, for example: 11-22.
3) Multiplication (") operation rule
FUNDPAY [ statinCode ] FUNDPAY [ deviveryErp ], as above, is the multiplication of the value 11 corresponding to statinCode and the value 22 corresponding to deviveryErp in the message, as follows: 11*22.
4) Division ("/") operation rule
FUNDPAY [ statinCode ]/FUNDPAY [ deviveryErp ] is as above, divided by the value 11 corresponding to statinCode and the value 22 corresponding to deviveryErp in the message, as follows: 11/22.
5) Assignment (═) operation rule
The assignment operation rule is applied to the storage of the temporary value, such as FUNDPAY _ TEMP [ tentative state code ] ═ FUNDPAY [ state code ], meaning that the value of the state code in the message is temporarily stored in the tentative state code field, and FUNDPAY _ TEMP is represented as the temporary value with the end of _ TEMP.
6) Function operation rule
The expression of FUNC _ start can be defined as a function, the purpose of the function is to solve some complex logic processing, such as traversing each row of a table, and then querying another table of a database according to a certain field in each row, if such logic is simply configured by a simple formula and is not enough to solve such a problem, so a function operation rule is defined to solve some problems that are not enough to be solved by a simple formula configuration, and a standard function is: the function name, the input parameters and the output parameters can be marked FUNC _onthe function name, and the background logic processing unit is explicitly told, which is a function statement, and the format of the function formula is as follows: FUNC-function name (INPUT: INPUT parameter list; OUT: output parameter list) can adopt java reflection method to solve the evaluation problem of function, and the specific function needs to be completed in code.
And step 204, executing at least one message processing formula based on the processing flow, the message key and the message value to obtain an execution result.
In the present embodiment, at least one message processing formula is executed with the message key and the message value as input parameters in the execution order specified by the processing flow. The message processing formula may be executed in different ways depending on the type of formula.
In some optional implementations of this embodiment, before executing the at least one message processing formula to obtain the execution result, the method further includes: determining a formula type of at least one message processing formula, wherein the formula type comprises at least one of: function type, assignment type and four operation types; and generating a second hash table according to the determined formula type and at least one message processing formula. For example, whether a formula character string starts with FUNC _ is judged, if yes, the formula is judged to be a function type, otherwise, whether an assignment symbol in the formula is equal to zero is judged, if yes, the formula is judged to be an assignment type, otherwise, the formula is judged to be an operation type of four.
In some optional implementations of this embodiment, executing at least one message processing formula to obtain an execution result includes: for each message processing formula in the second hash table, if the formula type of the message processing formula is the four-rule operation type, converting the message processing formula into a suffix expression, obtaining an execution result by using the suffix expression, and storing the execution result in the first hash table.
The steps of converting the message processing formula of the four operation types into the suffix expression are as follows:
a) an empty stack is initiated for use of symbols in and out of the stack.
b) And when the formula morpheme is encountered, the formula morpheme is directly output and added into a suffix expression.
c) And when an operator is encountered, directly stacking, encountering a left bracket, stacking the left bracket, encountering a right bracket, executing a pop operation, and outputting the popped element.
d) Other operators are encountered: addition, subtraction, multiplication and division: pop all top elements with priorities greater than or equal to the operator and then push the operator onto the stack.
e) Finally, elements in the stack are sequentially popped, and suffix expressions generated by four operation type formulas are stored, so that formula analysis is directly skipped when the next formula is executed, the analysis time is saved, and the programming idea of java compiling once and running everywhere is achieved.
In some optional implementations of this embodiment, executing at least one message processing formula to obtain an execution result includes: and for each message processing formula in the second hash table, if the formula type of the message processing formula is the function type, obtaining an execution result by using a java reflection method, and storing the execution result into the first hash table.
The principle of the java reflex method is as follows: after the Java is compiled, a class file is generated, and the Java virtual machine needs to interpret the class file at this time. When a program actively uses a certain class, if the class is not loaded in the memory, the Java virtual machine initializes the class through three steps:
1. loading: performed by a class loader, which looks up bytecodes and creates a class object from these bytecodes
2. Linking: the bytecode in a class will be verified in the chaining phase, memory space will be allocated for the static domain, and all references created by this class to other classes will be resolved if necessary.
3. Initialization: if the class has a super class, it is initialized, and a static initializer and a static initialization block are executed.
One, as in the three steps above, the class file is merged into the program for its invocation. In the first step, the bytecode is looked up and a class object is generated, which is always the object in Java. Class is also parsed into an object by the Java virtual machine. Thus, when the program is running, each java file finally becomes an instance of a Class object. By applying the reflection method of Java to this instance, we can obtain and even add the attribute and action that changes this class, so that this class becomes a dynamic class (the dynamic is defined by dynamic language-changes its structure when the program runs: new function can be introduced, existing function can be deleted, etc. the change in structure is changed).
In some optional implementations of this embodiment, the at least one message processing formula includes a function name, an input parameter, and an output parameter; and obtaining an execution result by using a java reflection method, wherein the execution result comprises the following steps: instantiating a class corresponding to the function name by using a java reflection method; and calling a class execution method based on the input parameters and the message values corresponding to the morphemes of the formulas in the first hash table, outputting an execution result to the output parameters, and storing the output parameters in the first hash table.
In some optional implementations of this embodiment, executing at least one message processing formula to obtain an execution result includes: and for each message processing formula in the second hash table, if the formula type of the message processing formula is the assignment type, taking the calculation result on one side of the message processing formula as an execution result, and storing the execution result in the first hash table.
Step 205, according to the execution result, executing database operation on the queried database.
In this embodiment, the content that needs to be saved in the execution result is stored in the database, or operations such as deletion, modification, query, and the like are performed on the database according to the execution result.
With continued reference to fig. 3, fig. 3 is a schematic diagram of an application scenario of the message processing method according to the present embodiment. In the application scenario of fig. 3, the user first sends a pending message 301 through the reporting application on the terminal. Then, the report server may receive the content of the message 301 to be processed, store the content in the message cache 303 through the receiving unit 302, and then invoke the message parsing unit and the formula parsing unit 304 to parse the message topic, the message key, and the message value in the message. And determining a message processing formula and a database needing to be operated which are involved in the associated processing flow according to the message subject 306. The message processing formula is executed by the execution unit 305, and the database 306 is operated according to the execution result.
According to the method provided by the embodiment of the application, the message to be processed is processed by using the message processing formula, so that manual operation is reduced, and the message processing efficiency is improved.
With further reference to fig. 4, a flow 400 of yet another embodiment of a message processing method is shown. The process 400 of the message processing method includes the following steps:
step 401, a message to be processed including a message topic, a message key and a message value is received.
At step 402, a database associated with a message topic is queried.
Step 403, acquiring a preset processing flow associated with the message topic.
At step 404, at least one message processing formula is executed based on the processing flow, the message key and the message value to obtain an execution result.
The steps 401 and 404 are substantially the same as the steps 201 and 204, and therefore, the description thereof is omitted.
At step 405, a database interaction formula associated with the process flow is obtained.
In this embodiment, the format of the database interaction formula is different from the common function formula, and is: the FUNC-function name (INPUT: INPUT parameter list; OUT: output parameter list; name of table) determined according to the execution result. When reflecting the function, operations such as addition, deletion, modification, query and the like are performed according to the name of the specified table.
Step 406, executing a database interaction formula by using a java reflection method to realize at least one of the following operations: add, modify, delete, query.
In this embodiment, after the message processing formula is executed, the data information is stored in the first hash table, the key value pair to be stored in the database is selected, and based on the preset database interactive formula, the key value pair is stored in the database by using a java reflection method. The steps of the java reflection method are the same as those described above, and therefore are not described in detail.
As can be seen from fig. 4, compared with the embodiment corresponding to fig. 2, the flow 400 of the message processing method in this embodiment highlights the step of performing the database operation by using the database interaction formula. Therefore, the message processing process is simplified, and the message processing efficiency is further improved.
With further reference to fig. 5, as an implementation of the method shown in the above-mentioned figures, the present application provides an embodiment of a message processing apparatus, which corresponds to the embodiment of the method shown in fig. 2, and which can be applied to various electronic devices.
As shown in fig. 5, the message processing apparatus 500 of the present embodiment includes: a receiving unit 501, an inquiring unit 502, an obtaining unit 503, an executing unit 504 and an operating unit 505. The receiving unit 501 is configured to receive a message to be processed, which includes a message topic, a message key, and a message value; the query unit 502 is used for querying a database associated with a message topic; the obtaining unit 503 is configured to obtain a preset processing flow associated with a message topic, where the processing flow corresponds to at least one message processing formula and is configured to process a message using at least one message processing formula, a message key, and a message value; the execution unit 504 is configured to execute at least one message processing formula based on the processing flow, the message key, and the message value to obtain an execution result; the operation unit 505 is configured to perform a database operation on the queried database according to an execution result.
In this embodiment, specific processing of the receiving unit 501, the querying unit 502, the obtaining unit 503, the executing unit 504 and the operating unit 505 of the message processing apparatus 500 may refer to step 201, step 202, step 203, step 204 and step 205 in the corresponding embodiment of fig. 2.
In some optional implementations of this embodiment, the apparatus 500 further includes: a message parsing unit (not shown) for parsing a message topic and at least one message key value pair of a message using a preset regular expression after receiving the message to be processed including the message topic, the message key and the message value; the first generating unit (not shown) is configured to, for each message key value pair in at least one message key value pair, separate a message key and a message value from the message key value pair, combine a message topic and the message key in the message key value pair into a formula morpheme according to a predetermined format, and then generate a first hash table according to the formula morpheme and the message value in the message key value pair.
In some optional implementations of this embodiment, the apparatus 500 further includes: a formula parsing unit (not shown) for determining a formula type of the at least one message processing formula before executing the at least one message processing formula to obtain an execution result, wherein the formula type includes at least one of: function type, assignment type and four operation types; a second generating unit (not shown) for generating a second hash table according to the determined formula type and the at least one message processing formula.
In some optional implementations of this embodiment, the execution unit 504 is further configured to: for each message processing formula in the second hash table, if the formula type of the message processing formula is the four-rule operation type, converting the message processing formula into a suffix expression, obtaining an execution result by using the suffix expression, and storing the execution result in the first hash table.
In some optional implementations of this embodiment, the execution unit 504 is further configured to: and for each message processing formula in the second hash table, if the formula type of the message processing formula is the function type, obtaining an execution result by using a java reflection method, and storing the execution result into the first hash table.
In some optional implementations of this embodiment, the at least one message processing formula includes a function name, an input parameter, and an output parameter; and the execution unit 504 is further configured to: instantiating a class corresponding to the function name by using a java reflection method; and calling an execution device of the class based on the input parameters and the message values corresponding to the morphemes of the formulas in the first hash table, outputting the execution result to the output parameters, and storing the output parameters in the first hash table.
In some optional implementations of this embodiment, the execution unit 504 is further configured to: and for each message processing formula in the second hash table, if the formula type of the message processing formula is the assignment type, taking the calculation result on one side of the message processing formula as an execution result, and storing the execution result in the first hash table.
In some optional implementations of the present embodiment, the operation unit 505 is further configured to: acquiring a database interaction formula associated with a processing flow; executing a database interaction formula by using a java reflection method to realize at least one of the following operations: add, modify, delete, query.
Referring now to FIG. 6, a block diagram of a computer system 600 suitable for use in implementing a terminal device/server of an embodiment of the present application is shown. The terminal device/server shown in fig. 6 is only an example, and should not bring any limitation to the functions and the scope of use of the embodiments of the present application.
As shown in fig. 6, the computer system 600 includes a Central Processing Unit (CPU)601 that can perform various appropriate actions and processes according to a program stored in a Read Only Memory (ROM)602 or a program loaded from a storage section 608 into a Random Access Memory (RAM) 603. In the RAM 603, various programs and data necessary for the operation of the system 600 are also stored. The CPU 601, ROM 602, and RAM 603 are connected to each other via a bus 604. An input/output (I/O) interface 605 is also connected to bus 604.
The following components are connected to the I/O interface 605: an input portion 606 including a keyboard, a mouse, and the like; an output portion 607 including a display such as a Cathode Ray Tube (CRT), a Liquid Crystal Display (LCD), and the like, and a speaker; a storage section 608 including a hard disk and the like; and a communication section 609 including a network interface card such as a LAN card, a modem, or the like. The communication section 609 performs communication processing via a network such as the internet. The driver 610 is also connected to the I/O interface 605 as needed. A removable medium 611 such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, or the like is mounted on the drive 610 as necessary, so that a computer program read out therefrom is mounted in the storage section 608 as necessary.
In particular, according to an embodiment of the present disclosure, the processes described above with reference to the flowcharts may be implemented as computer software programs. For example, embodiments of the present disclosure include a computer program product comprising a computer program embodied on a computer readable medium, the computer program comprising program code for performing the method illustrated in the flow chart. In such an embodiment, the computer program may be downloaded and installed from a network through the communication section 609, and/or installed from the removable medium 611. The computer program performs the above-described functions defined in the method of the present application when executed by a Central Processing Unit (CPU) 601. It should be noted that the computer readable medium described herein can be a computer readable signal medium or a computer readable storage medium or any combination of the two. A computer readable storage medium may be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the foregoing. More specific examples of the computer readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the present application, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. In this application, however, a computer readable signal medium may include a propagated data signal with computer readable program code embodied therein, for example, in baseband or as part of a carrier wave. Such a propagated data signal may take many forms, including, but not limited to, electro-magnetic, optical, or any suitable combination thereof. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, fiber optic cable, RF, etc., or any suitable combination of the foregoing.
The flowchart and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present application. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams and/or flowchart illustration, and combinations of blocks in the block diagrams and/or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
The units described in the embodiments of the present application may be implemented by software or hardware. The described units may also be provided in a processor, and may be described as: a processor includes a receiving unit, a querying unit, an acquisition unit, an execution unit, and an operation unit. Where the names of these elements do not in some cases constitute a limitation of the element itself, for example, a receiving element may also be described as an "element that receives a message to be processed including a message subject, a message key, and a message value".
As another aspect, the present application also provides a computer-readable medium, which may be contained in the apparatus described in the above embodiments; or may be present separately and not assembled into the device. The computer readable medium carries one or more programs which, when executed by the apparatus, cause the apparatus to: receiving a message to be processed comprising a message topic, a message key and a message value; querying a database associated with the message topic; acquiring a preset processing flow associated with a message theme, wherein the processing flow corresponds to at least one message processing formula, and the message is processed by using the at least one message processing formula, a message key and a message value; executing at least one message processing formula based on the processing flow, the message key and the message value to obtain an execution result; and executing database operation on the inquired database according to the execution result.
The above description is only a preferred embodiment of the application and is illustrative of the principles of the technology employed. It will be appreciated by a person skilled in the art that the scope of the invention as referred to in the present application is not limited to the embodiments with a specific combination of the above-mentioned features, but also covers other embodiments with any combination of the above-mentioned features or their equivalents without departing from the inventive concept. For example, the above features may be replaced with (but not limited to) features having similar functions disclosed in the present application.

Claims (16)

1. A method of message processing, the method comprising:
receiving a message to be processed comprising a message topic, a message key and a message value;
analyzing the message theme and at least one message key value pair of the message by using a preset regular expression;
for each message key value pair in the at least one message key value pair, separating a message key and a message value from the message key value pair, combining the message theme and the message key in the message key value pair into a formula morpheme according to a preset format, and then generating a first hash table according to the formula morpheme and the message value in the message key value pair;
querying a database associated with the message topic;
acquiring a preset processing flow associated with the message theme, wherein the processing flow corresponds to at least one message processing formula and is used for processing the message by using the at least one message processing formula, the message key and the message value;
executing the at least one message processing formula based on the processing flow, the message key and the message value to obtain an execution result;
and executing database operation on the inquired database according to the execution result.
2. The method of claim 1, wherein before said executing said at least one message processing formula results in an execution result, said method further comprises:
determining a formula type of the at least one message processing formula, wherein the formula type comprises at least one of: function type, assignment type and four operation types;
and generating a second hash table according to the determined formula type and the at least one message processing formula.
3. The method of claim 2, wherein said executing the at least one message processing formula results in an execution result comprising:
for each message processing formula in the second hash table, if the formula type of the message processing formula is the four-rule operation type, converting the message processing formula into a suffix expression, obtaining an execution result by using the suffix expression, and storing the execution result in the first hash table.
4. The method of claim 2, wherein said executing the at least one message processing formula results in an execution result comprising:
for each message processing formula in the second hash table, if the formula type of the message processing formula is a function type, obtaining an execution result by using a java reflection method, and storing the execution result in the first hash table.
5. The method of claim 4, wherein the at least one message processing formula comprises a function name, an input parameter, and an output parameter; and
the method for obtaining the execution result by using the java reflection method comprises the following steps:
instantiating the class corresponding to the function name by using a java reflection method;
and calling the class execution method based on the input parameters and the message values corresponding to the morphemes of the formulas in the first hash table, outputting the execution result to the output parameters, and storing the output parameters in the first hash table.
6. The method of claim 2, wherein said executing the at least one message processing formula results in an execution result comprising:
and for each message processing formula in the second hash table, if the formula type of the message processing formula is an assignment type, taking a calculation result on one side of the message processing formula as an execution result, and storing the execution result in the first hash table.
7. The method according to any one of claims 1-6, wherein the performing the database operation on the queried database according to the execution result comprises:
acquiring a database interaction formula associated with the processing flow;
executing the database interaction formula by using a java reflection method to realize at least one of the following operations: add, modify, delete, query.
8. A message processing apparatus, characterized in that the apparatus comprises:
the receiving unit is used for receiving the message to be processed, which comprises a message theme, a message key and a message value;
the message analysis unit is used for analyzing the message theme and at least one message key value pair of the message by using a preset regular expression after receiving the message to be processed comprising the message theme, the message keys and the message values;
a first generating unit, configured to separate, for each message key value pair in the at least one message key value pair, a message key and a message value from the message key value pair, combine the message topic and the message key in the message key value pair into a formula morpheme according to a predetermined format, and then generate a first hash table according to the formula morpheme and the message value in the message key value pair;
the query unit is used for querying a database associated with the message subject;
an obtaining unit, configured to obtain a preset processing flow associated with the message topic, where the processing flow corresponds to at least one message processing formula and is used to process the message by using the at least one message processing formula, the message key, and the message value;
the execution unit is used for executing the at least one message processing formula based on the processing flow, the message key and the message value to obtain an execution result;
and the operation unit is used for executing database operation on the inquired database according to the execution result.
9. The apparatus of claim 8, further comprising:
the formula analysis unit is used for determining a formula type of the at least one message processing formula before executing the at least one message processing formula to obtain an execution result, wherein the formula type comprises at least one of the following items: function type, assignment type and four operation types;
and the second generating unit is used for generating a second hash table according to the determined formula type and the at least one message processing formula.
10. The apparatus of claim 9, wherein the execution unit is further configured to:
for each message processing formula in the second hash table, if the formula type of the message processing formula is the four-rule operation type, converting the message processing formula into a suffix expression, obtaining an execution result by using the suffix expression, and storing the execution result in the first hash table.
11. The apparatus of claim 9, wherein the execution unit is further configured to:
for each message processing formula in the second hash table, if the formula type of the message processing formula is a function type, obtaining an execution result by using a java reflection method, and storing the execution result in the first hash table.
12. The apparatus of claim 11, wherein the at least one message processing formula comprises a function name, an input parameter, and an output parameter; and
the execution unit is further to:
instantiating the class corresponding to the function name by using a java reflection method;
and calling the class execution device based on the input parameters and the message values corresponding to the morphemes of the formulas in the first hash table, outputting the execution result to the output parameters, and storing the output parameters in the first hash table.
13. The apparatus of claim 9, wherein the execution unit is further configured to:
and for each message processing formula in the second hash table, if the formula type of the message processing formula is an assignment type, taking a calculation result on one side of the message processing formula as an execution result, and storing the execution result in the first hash table.
14. The apparatus according to one of claims 8-13, wherein the operating unit is further configured to:
acquiring a database interaction formula associated with the processing flow;
executing the database interaction formula by using a java reflection method to realize at least one of the following operations: add, modify, delete, query.
15. An apparatus, comprising:
one or more processors;
storage means for storing one or more programs;
when executed by the one or more processors, cause the one or more processors to implement the method of any one of claims 1-7.
16. A computer-readable storage medium, on which a computer program is stored which, when being executed by a processor, carries out the method according to any one of claims 1-7.
CN201710982048.0A 2017-10-20 2017-10-20 Message processing method and device Active CN110069514B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201710982048.0A CN110069514B (en) 2017-10-20 2017-10-20 Message processing method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201710982048.0A CN110069514B (en) 2017-10-20 2017-10-20 Message processing method and device

Publications (2)

Publication Number Publication Date
CN110069514A CN110069514A (en) 2019-07-30
CN110069514B true CN110069514B (en) 2021-08-17

Family

ID=67364468

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201710982048.0A Active CN110069514B (en) 2017-10-20 2017-10-20 Message processing method and device

Country Status (1)

Country Link
CN (1) CN110069514B (en)

Family Cites Families (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103209153B (en) * 2012-01-16 2016-03-16 阿里巴巴集团控股有限公司 Message treatment method, Apparatus and system
CN103279532B (en) * 2013-05-31 2016-12-28 北京创世泰克科技股份有限公司 Many set elements duplicate removal also identifies the affiliated filtration system gathered and method thereof
CN103279358B (en) * 2013-06-08 2016-04-27 北京首钢自动化信息技术有限公司 A kind of explanation type Service Component dynamic fixing method of Industry-oriented application
CN105471703A (en) * 2014-08-27 2016-04-06 北京奇虎科技有限公司 Message sending method and device
US10810200B2 (en) * 2015-01-07 2020-10-20 International Business Machines Corporation Technology for join processing
CN106407480B (en) * 2016-11-29 2020-02-04 北京世纪高通科技有限公司 Information query method and system

Also Published As

Publication number Publication date
CN110069514A (en) 2019-07-30

Similar Documents

Publication Publication Date Title
CN106980504B (en) Application program development method and tool and equipment thereof
US8959477B2 (en) Scripting language for business applications
US8392467B1 (en) Directing searches on tree data structures
CN110764748B (en) Code calling method, device, terminal and storage medium
US10572278B2 (en) Smart controls for user interface design and implementation
CN110020358B (en) Method and device for generating dynamic page
CN111324833A (en) Page display method, device, electronic design and computer readable medium
CN110795649A (en) Target page display method, device and system and electronic equipment
CN110109983B (en) Method and device for operating Redis database
CN111125064A (en) Method and device for generating database mode definition statement
CN115599386A (en) Code generation method, device, equipment and storage medium
US9606844B2 (en) Remotely-hosted interactive client-server session
US8234586B2 (en) User interface framework and techniques
CN110888794A (en) Interface test method and device
CN113761871A (en) Rich text rendering method and device, electronic equipment and storage medium
CN108073401B (en) Method and device for executing business logic and electronic equipment
CN115982491A (en) Page updating method and device, electronic equipment and computer readable storage medium
US20220284371A1 (en) Method, device and medium for a business function page
CN110069514B (en) Message processing method and device
CN113760969A (en) Data query method and device based on elastic search
CN114489607A (en) Cross-stack application processing and page rendering method, device, equipment and storage medium
CN113094561A (en) Webpage generation method, webpage generation device, electronic equipment and storage medium
CN113760292A (en) Method and device for developing application program, electronic equipment and storage medium
CN112068814A (en) Method, device, system and medium for generating executable file
CN111078230A (en) Code generation method and device

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant