CN115220877B - Service processing method and device - Google Patents
Service processing method and device Download PDFInfo
- Publication number
- CN115220877B CN115220877B CN202210837295.2A CN202210837295A CN115220877B CN 115220877 B CN115220877 B CN 115220877B CN 202210837295 A CN202210837295 A CN 202210837295A CN 115220877 B CN115220877 B CN 115220877B
- Authority
- CN
- China
- Prior art keywords
- message
- target transaction
- processing logic
- consumed
- persistence
- 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
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements 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/46—Multiprogramming arrangements
- G06F9/466—Transaction processing
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements 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/46—Multiprogramming arrangements
- G06F9/54—Interprogram communication
- G06F9/546—Message passing systems or structures, e.g. queues
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F2209/00—Indexing scheme relating to G06F9/00
- G06F2209/54—Indexing scheme relating to G06F9/54
- G06F2209/547—Messaging middleware
-
- Y—GENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
- Y02—TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
- Y02D—CLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
- Y02D10/00—Energy efficient computing, e.g. low power processors, power management or thermal management
Landscapes
- Engineering & Computer Science (AREA)
- Software Systems (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
Abstract
The application provides a business processing method and a business processing device, which are used for generating a corresponding first target transaction and a message to be consumed according to a received business request; executing a first target transaction and acquiring a first submitting result of the first target transaction; judging whether the first commit result is that the first target transaction is committed; and if the first commit result is that the first target transaction is committed, sending the message to be consumed to the message middleware, wherein the first target transaction committed indicates that the first business processing logic and the first persistence processing logic encapsulated in the first target transaction are successfully executed at the same time. According to the method and the device, the message persistence and the business processing operation are packaged into the same transaction execution, so that the reliability of message transmission is further improved.
Description
Technical Field
The present disclosure relates to the field of service processing technologies, and in particular, to a service processing method and apparatus.
Background
With the development of the internet and the wide application of the distributed system, the message middleware gradually becomes a core communication means inside the enterprise IT system, and utilizes an efficient and reliable message transmission mechanism to perform asynchronous data transmission and call, and performs integration of the distributed system based on data communication, and the message middleware mainly plays roles of decoupling and flow peak clipping in the whole system.
In actual service, the message middleware is introduced, meanwhile, the complexity of the system is increased, the professional requirement degree is higher for system developers, the sending of the message and the service operation are easy to be inconsistent, and the reliability of the message transmission cannot be ensured.
Disclosure of Invention
In view of this, an object of the present application is to provide at least a service processing method and apparatus, which further improves the reliability of message transmission by encapsulating message persistence and service processing operations into the same transaction execution.
The application mainly comprises the following aspects:
in a first aspect, an embodiment of the present application provides a service processing method, where the method includes:
generating a corresponding first target transaction and a message to be consumed according to the received service request; executing a first target transaction and acquiring a first submitting result of the first target transaction; judging whether the first commit result is that the first target transaction is committed; and if the first commit result is that the first target transaction is committed, sending the message to be consumed to the message middleware, wherein the first target transaction committed indicates that the first business processing logic and the first persistence processing logic encapsulated in the first target transaction are successfully executed at the same time.
In one possible embodiment, after the step of sending the message to be consumed to the message middleware, the method further comprises: extracting a message to be consumed from the message middleware, and generating a second target transaction according to the message to be consumed; executing a second target transaction, and acquiring a second submitting result corresponding to the second target transaction; and according to the second submitting result, finishing the processing of the service request.
In one possible implementation, the step of generating the corresponding first target transaction according to the received service request includes: according to the received service request, determining first service processing logic and first persistence processing logic aiming at a first database, wherein the first persistence processing logic is used for carrying out persistence processing on the message to be consumed in the first database; the first business processing logic and the first persistence processing logic for the message to be consumed are encapsulated as a first target transaction.
In one possible implementation, the step of encapsulating the first business processing logic and the first persistence processing logic for the message to be consumed as a first target transaction comprises: adding the same transaction identifier for a first service processing logic and a first persistence processing logic aiming at a message to be consumed through a preset software development kit; and forming a first target transaction by the first business processing logic and the first persistence processing logic after adding the identity.
In one possible implementation, after the step of determining whether the first commit result is that the first target transaction has committed, the method further includes: and if the first commit result is that the first target transaction is not committed, the first database controlling the operation of the first persistence processing logic is restored to the state before the first target transaction is committed, and the first target transaction is not committed and indicates that the first business processing logic and/or the first persistence processing logic fails to execute.
In one possible embodiment, the method further comprises: the message middleware generates a receiving state aiming at the message to be consumed according to the received message to be consumed; the message middleware feeds back the receiving state to a sending end of the message to be consumed; and the sending end updates the sending state of the message to be consumed according to the receiving state.
In one possible implementation, the receiving status includes a message reception success and a message reception failure, and the method further includes: if the receiving state is that the message is successfully received, the sending end updates the sending state of the message to be consumed from the pre-sending state to the sent state; if the receiving state is not received by the transmitting end or the receiving state is the message receiving failure, the transmitting end resends the message until the receiving state is the message receiving success, and the transmitting state of the message to be consumed is updated from the pre-transmitting state to the transmitted state.
In one possible implementation, the step of determining the second target transaction from the message to be consumed includes: determining second business processing logic and second persistence processing logic aiming at a second database according to the received message to be consumed, wherein the second persistence processing logic is used for carrying out persistence processing on the message to be consumed in the second database; and encapsulating the second business processing logic and the second persistence processing logic into a second target transaction.
In one possible implementation manner, the step of completing the processing of the service request according to the second submitting result further includes: determining the current consumption progress of the message to be consumed according to the second submitting result; and finishing the processing of the service request according to the current consumption progress.
In one possible implementation, the step of determining the current consumption progress for the message to be consumed according to the second submission result includes: judging whether the second commit result is that the second target transaction is committed; if the second submitting result is that the second target transaction is submitted, submitting the consumption progress to a second database, wherein the second target transaction is submitted to indicate that the second business processing logic and the second persistence processing logic are successfully executed at the same time; updating the current consumption progress of the message to be consumed in the second database; if the second commit result is that the second target transaction is not committed, controlling second business processing logic and second persistence processing logic in the second target transaction to automatically roll back, wherein the second target transaction is not committed and indicates that the execution of the second business processing logic and/or the second persistence processing logic fails; obtaining a persistence result corresponding to the second persistence processing logic; and determining the current consumption progress aiming at the message to be consumed according to the persistence result corresponding to the second persistence processing logic.
In one possible implementation, the step of determining the current consumption progress for the message to be consumed according to the persistence result corresponding to the second persistence processing logic includes: if the persistence result indicates that the message to be consumed has been stored to the second database, then: submitting the consumption progress to a second database; determining the current consumption progress of the message to be consumed in the second database; if the persistence result indicates that the message to be consumed is not stored to the second database, then: restoring the second database to a second target transaction pre-execution state; and consuming the message to be consumed again to acquire the current consumption progress.
In a third aspect, an embodiment of the present application further provides a service processing apparatus, where the service processing apparatus includes: generating a corresponding first target transaction and a message to be consumed according to the received service request; executing a first target transaction and acquiring a first submitting result of the first target transaction; judging whether the first commit result is that the first target transaction is committed; and if the first commit result is that the first target transaction is committed, sending the message to be consumed to the message middleware, wherein the first target transaction committed indicates that the first business processing logic and the first persistence processing logic encapsulated in the first target transaction are successfully executed at the same time.
The embodiment of the application provides a service processing method and device, which are used for generating a corresponding first target transaction and a message to be consumed according to a received service request; executing a first target transaction and acquiring a first submitting result of the first target transaction; judging whether the first commit result is that the first target transaction is committed; and if the first commit result is that the first target transaction is committed, sending the message to be consumed to the message middleware, wherein the first target transaction committed indicates that the first business processing logic and the first persistence processing logic encapsulated in the first target transaction are successfully executed at the same time. According to the method and the device, the message persistence and the business processing operation are packaged into the same transaction execution, so that the reliability of message transmission is further improved.
In order to make the above objects, features and advantages of the present application more comprehensible, preferred embodiments accompanied with figures are described in detail below.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings that are needed in the embodiments will be briefly described below, it being understood that the following drawings only illustrate some embodiments of the present application and therefore should not be considered limiting the scope, and that other related drawings may be obtained according to these drawings without inventive effort for a person skilled in the art.
Fig. 1 shows a schematic structural diagram of a service processing system according to an embodiment of the present application;
fig. 2 shows a flowchart of steps of a service processing method according to an embodiment of the present application;
fig. 3 shows a second flowchart of steps of a service processing method according to an embodiment of the present application;
fig. 4 shows a flowchart III of steps of a service processing method provided in an embodiment of the present application;
fig. 5 shows a schematic diagram of a functional module of a service processing device according to an embodiment of the present application;
fig. 6 shows a second functional block diagram of a service processing device according to an embodiment of the present application;
fig. 7 shows a schematic diagram of a functional module of a service processing device according to an embodiment of the present application;
fig. 8 shows a schematic structural diagram of an electronic device according to an embodiment of the present application.
Detailed Description
For the purpose of making the objects, technical solutions and advantages of the embodiments of the present application more clear, the technical solutions of the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present application, and it should be understood that the accompanying drawings in the present application are only for the purpose of illustration and description, and are not intended to limit the protection scope of the present application. In addition, it should be understood that the schematic drawings are not drawn to scale. A flowchart, as used in this application, illustrates operations implemented according to some embodiments of the present application. It should be appreciated that the operations of the flow diagrams may be implemented out of order and that steps without logical context may be performed in reverse order or concurrently. Moreover, one or more other operations may be added to the flow diagrams and one or more operations may be removed from the flow diagrams as directed by those skilled in the art.
In addition, the described embodiments are only some, but not all, of the embodiments of the present application. The components of the embodiments of the present application, which are generally described and illustrated in the figures herein, may be arranged and designed in a wide variety of different configurations. Thus, the following detailed description of the embodiments of the present application, as provided in the accompanying drawings, is not intended to limit the scope of the application, as claimed, but is merely representative of selected embodiments of the application. All other embodiments, which can be made by those skilled in the art based on the embodiments of the present application without making any inventive effort, are intended to be within the scope of the present application.
In the prior art, the complexity of a system is increased to a certain extent based on message middleware for message transmission, and the professional requirement for system developers is higher, in actual business, in any occurrence of message sending and business operation, namely, inconsistency of message sending and business operation execution can be caused, and the inconsistency of message sending and business operation can cause business processing failure or business processing errors, for example:
when the operation of the business aiming at the database is not submitted, the message processing is likely to be successful, and the business operation fails to roll back;
or, if the service is submitted to be completed for the database transaction and the message is processed again, the service may be completed, and the message processing may fail due to network or other reasons.
Based on this, the embodiment of the application provides a service processing system, which further improves the reliability of message transmission by encapsulating message persistence and service processing operation into the same transaction execution, specifically as follows:
referring to fig. 1, fig. 1 is a schematic structural diagram of a service processing system according to an embodiment of the present application. As shown in fig. 1, the service processing system includes a sending end 10, a first database 20 corresponding to the sending end 10, a message middleware 30, a receiving end 40, and a second database 50 corresponding to the receiving end, wherein, referring to fig. 2, fig. 2 shows a flowchart of steps of a service processing method provided in an embodiment of the present application, as shown in fig. 2, the sending end 10 is configured to:
s110, generating a corresponding first target transaction and a message to be consumed according to the received service request.
In a preferred embodiment, the user may initiate a service request through the sender 10, and after the sender 10 responds to the service request, the first target transaction for the first database 50 and the corresponding message to be consumed are determined according to the content indicated by the service request.
In a specific embodiment, the step of generating the corresponding first target transaction according to the received service request includes:
according to the received service request, determining first service processing logic and first persistence processing logic for the first database, and packaging the first service processing logic and the first persistence processing logic for the message to be consumed into a first target transaction, wherein the first service processing logic for the first database 20 is determined according to the content indicated by the service request, and the first persistence processing logic is used for persistence processing the message to be consumed in the first database.
Specifically, the message to be consumed is specific content corresponding to the service request, for example, the service request is a transfer request, the specific content related to the transfer request is that the sender 10 transfers 100 to the receiver 40, and the first service processing logic performs a deduction 100 element operation for the first database 20, and the message to be consumed is that the sender 10 indicated by the transfer request transfers 100 to the receiver 40.
In a preferred embodiment, the step of encapsulating the first business processing logic and the first persistence processing logic for the message to be consumed as a first target transaction comprises:
adding the same transaction identifier for a first service processing logic and a first persistence processing logic aiming at a message to be consumed through a preset software development kit; and forming a first target transaction by the first business processing logic and the first persistence processing logic after adding the identity.
In a specific embodiment, the sending end 10 is preloaded with a software development kit, the same transaction identifier is added for the first business processing logic and the first persistence processing logic for the message to be consumed through the encapsulation logic in the software development kit, the first persistence processing logic and the first persistence processing logic after the same transaction identifier is added form a first target transaction, and specifically, the starting annotation is further added on the first target transaction through the software development kit, so that the quick starting of the first target transaction can be realized, wherein the first persistence processing logic is used for storing the message to be consumed in the first database, and specifically, the first business processing logic and the first persistence processing logic encapsulated into the first target transaction can realize the simultaneous execution success and the simultaneous execution failure.
S120, executing the first target transaction and acquiring a first submitting result of the first target transaction.
In a preferred embodiment, the first commit result is that the first target transaction has committed or that the first target transaction has not committed.
S130, judging whether the first commit result is that the first target transaction is committed.
And S140, if the first submitting result is that the first target transaction is submitted, sending the message to be consumed to the message middleware.
Wherein, the first target transaction is submitted to indicate that the first business processing logic and the first persistence processing logic encapsulated in the first target transaction are executed successfully at the same time, and at this time, the sender 10 automatically invokes the saved message to be consumed from the first database 20 and sends the saved message to the message middleware 30.
In one embodiment, after the execution of the first target transaction is completed, the first database 20 is updated, for example, the message to be consumed is saved to the first database 20 after the successful execution of the first persistence processing logic, the execution of the first business processing logic changes the data of the first database 20 itself, for example, the first business processing logic is 100 points deducted, the balance of money in the first database 20 is reduced by 100 points, and the remaining money in the first database 20 is updated, that is, if the first commit result is that the first target transaction has been committed, all the modifications performed on the first database 20 are saved.
After step S130, the method further comprises:
and S150, if the first commit result is that the first target transaction is not committed, controlling the first database of the first persistence processing logic operation to restore to the state before the first target transaction is committed.
The first target transaction non-commit indicates that the first business processing logic and/or the first persistence processing logic fails to execute, if any processing logic in the first business processing logic and the first persistence processing logic fails to commit, rollback operation is executed, the first database returns to a state before the first target transaction is submitted, the flow is ended, the sending of the message to be consumed is canceled, and the response to the business request is executed again.
Referring to fig. 3, fig. 3 is a flowchart showing steps of a service processing method according to an embodiment of the present application. As shown in fig. 3, the message middleware 30 is further configured to:
s210, generating a receiving state for the message to be consumed according to the received message to be consumed.
S220, feeding back the receiving state to the sending end of the message to be consumed.
In a preferred embodiment, after receiving the message to be consumed, the message middleware 30 returns a receiving status for the message to be consumed to the sender 10, where the receiving status includes a successful message receiving and a failed message receiving, and the receiving status can be determined by an ACK acknowledgement character returned by the message middleware 30, if the sender 10 receives the ACK acknowledgement character, the receiving status is the successful message receiving, and if the sender 10 does not receive the ACK acknowledgement character, the receiving status is the failed message sending.
The transmitting end 10 is further configured to:
and updating the sending state of the message to be consumed according to the receiving state.
In a preferred embodiment, if the receiving status is successful in receiving the message, the sending end updates the sending status of the message to be consumed from the pre-sending status to the sent status, and if the sending end does not receive the receiving status or the receiving status is failed in receiving the message, the sending end resends the message until the receiving status is successful in receiving the message, and updates the sending status of the message to be consumed from the pre-sending status to the sent status.
In a specific embodiment, when the message to be consumed has been successfully sent to the message middleware, but the modification of the sending state of the message to be consumed fails, the message to be consumed may be repeatedly sent to the message middleware, and based on this, the receiving end 40 provided in the present application may prevent the message to be consumed from being executed multiple times.
Specifically, referring to fig. 4, fig. 4 shows a flowchart three of steps of a service processing method provided in the embodiment of the present application, and as shown in fig. 4, the receiving end 40 is configured to:
and S300, extracting the message to be consumed from the message middleware, and generating a second target transaction according to the message to be consumed.
Specifically, the receiving end 40 extracts the subscribed message to be consumed from the message middleware in the form of subscription.
Wherein the step of generating a second target transaction from the message to be consumed comprises:
and determining second business processing logic and second persistence processing logic aiming at a second database according to the received message to be consumed, packaging the second business processing logic and the second persistence processing logic into a second target transaction, wherein the second persistence processing logic is used for carrying out persistence processing on the message to be consumed in the second database.
In a preferred embodiment, after the receiving end 40 obtains the message to be consumed, the second service processing logic for the second database is generated to complete the consumption of the message to be consumed, so as to complete the whole service request, for example, for the message to be consumed, the sending end 10 transfers 100 to the receiving end 40, and the second service processing logic performs the money adding 100-element operation for the second database 50.
In a specific embodiment, the receiving end 40 also introduces a software development kit, the acquiring manner of the second target transaction is the same as that of the first target transaction, which is not described herein, and specifically, the second service processing logic and the second persistence processing logic encapsulated into the second target transaction may implement simultaneous execution success and simultaneous execution failure.
S310, executing a second target transaction, and acquiring a second commit result corresponding to the second target transaction.
In a preferred embodiment, the second commit result is that the second target transaction has committed or that the second target transaction has not committed.
S320, according to the second submitting result, the processing of the service request is completed.
According to the second submitting result, the step of completing the processing of the service request further comprises:
and determining the current consumption progress aiming at the message to be consumed according to the second submitting result, and completing the processing of the service request according to the current consumption progress.
Wherein, according to the second submitting result, the step of determining the current consumption progress of the message to be consumed comprises:
whether the second commit result is that the second target transaction has committed is determined.
And if the second submitting result is that the second target transaction is submitted, submitting the consumption progress to a second database, wherein the second target transaction is submitted to indicate that the second business processing logic and the second persistence processing logic are successfully executed at the same time, and updating the current consumption progress of the message to be consumed in the second database.
In a preferred embodiment, if the second commit result is that the second target transaction has been committed, it indicates that the consumption of the message to be consumed is completed successfully, that is, the processing of the service request is completed, and after the current consumption progress is committed, the whole service flow is ended.
If the second submitting result is that the second target transaction is not submitted, controlling second business processing logic and second persistence processing logic in the second target transaction to automatically roll back, obtaining persistence results corresponding to the second persistence processing logic, and determining the current consumption progress of the message to be consumed according to the persistence results corresponding to the second persistence processing logic, wherein the second target transaction is not submitted and indicates that the second business processing logic and/or the second persistence processing logic fails to execute.
In a specific embodiment, the message to be consumed is only persisted once in the same database, so if the second commit result is that the second target transaction is not committed, it is indicated that the second service processing logic and/or the second persisting processing logic fails to execute, and the consumption of the message to be consumed is not completed successfully, and it is also required to confirm whether the message to be consumed has been saved to the first database before the second target transaction is executed this time.
In a preferred embodiment, the step of determining the current consumption progress for the message to be consumed according to the persistence result corresponding to the second persistence processing logic comprises:
if the persistence result indicates that the message to be consumed has been stored to the second database, then: submitting the consumption progress to a second database, and determining the current consumption progress of the message to be consumed in the second database.
In a preferred embodiment, if the message to be consumed is stored in the second database and the second service processing logic submits successfully, it indicates that the consumption of the message to be consumed is completed, and the consumption progress is submitted directly, and the processing flow of the service request is finished.
If the persistence result indicates that the message to be consumed is not stored to the second database, then: restoring the second database to a second target transaction pre-execution state; and consuming the message to be consumed again to acquire the current consumption progress.
In another preferred embodiment, if the message to be consumed is not stored in the second database, it indicates that the execution of the message to be consumed fails, and the second database returns to the state before the execution of the second target transaction to consume the message again.
Based on the same application conception, the embodiment of the present application further provides a service processing device corresponding to the service processing method provided by the foregoing embodiment, and since the principle of solving the problem by the device in the embodiment of the present application is similar to that of the service processing method in the foregoing embodiment of the present application, implementation of the device may refer to implementation of the method, and repeated parts are omitted.
Referring to fig. 5, fig. 5 shows a schematic diagram of a functional module of a service processing apparatus according to an embodiment of the present application, and as shown in fig. 5, the service processing apparatus includes:
a service request receiving module 410, configured to generate a corresponding first target transaction and a message to be consumed according to the received service request;
a first execution module 420, configured to execute a first target transaction and obtain a first commit result of the first target transaction;
a determining module 430, configured to determine whether the first commit result is that the first target transaction has been committed;
and the sending module 440 is configured to send the message to be consumed to the message middleware if the first commit result is that the first target transaction has been committed, where the first target transaction committed indicates that the first business processing logic and the first persistence processing logic encapsulated in the first target transaction are executed successfully at the same time.
The service request receiving module 410, the first executing module 420, the judging module 430, and the sending module 440 are installed on the sending end.
Referring to fig. 6, fig. 6 shows a second functional block diagram of a service processing apparatus according to an embodiment of the present application, and as shown in fig. 6, the service processing apparatus further includes:
a receiving state generating module 450, configured to generate a receiving state for the message to be consumed according to the received message to be consumed;
a feedback module 460, configured to feed back the receiving status to a sending end of the message to be consumed;
wherein the receiving status generation module 450 and the feedback module 460 are loaded on the message middleware.
Referring to fig. 7, fig. 7 shows a functional block diagram three of a service processing apparatus according to an embodiment of the present application, and as shown in fig. 7, the service processing apparatus further includes:
an extracting module 470, configured to extract a message to be consumed from the message middleware, and generate a second target transaction according to the message to be consumed;
a second execution module 480, configured to execute a second target transaction, and obtain a second commit result corresponding to the second target transaction;
and a processing module 490 for completing the processing of the service request according to the second submitting result.
Wherein the extraction module 470, the second execution module 480, and the processing module 490 are loaded on the receiving end.
Based on the same application concept, referring to fig. 8, fig. 8 shows a schematic structural diagram of an electronic device provided in an embodiment of the present application, and as shown in fig. 8, an electronic device 500 includes: a processor 510, a memory 520 and a bus 530, the memory 520 storing machine readable instructions executable by the processor 510, the processor 510 and the memory 520 communicating via the bus 530 when the electronic device 500 is running, the machine readable instructions being executable by the processor 510 to perform the steps of the traffic handling method according to any of the embodiments described above.
Based on the same application concept, the embodiment of the present application further provides a computer readable storage medium, where a computer program is stored, where the computer program is executed by a processor to perform the steps of the service processing method provided in the foregoing embodiment.
It will be clear to those skilled in the art that, for convenience and brevity of description, specific working procedures of the above-described system and apparatus may refer to corresponding procedures in the foregoing method embodiments, which are not described herein again. In the several embodiments provided in this application, it should be understood that the disclosed systems, devices, and methods may be implemented in other manners. The above-described apparatus embodiments are merely illustrative, for example, the division of the units is merely a logical function division, and there may be other manners of division in actual implementation, and for example, multiple units or components may be combined or integrated into another system, or some features may be omitted, or not performed. Alternatively, the coupling or direct coupling or communication connection shown or discussed with each other may be through some communication interface, device or unit indirect coupling or communication connection, which may be in electrical, mechanical or other form.
The units described as separate units may or may not be physically separate, and units shown as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
In addition, each functional unit in each embodiment of the present application may be integrated in one processing unit, or each unit may exist alone physically, or two or more units may be integrated in one unit.
The functions, if implemented in the form of software functional units and sold or used as a stand-alone product, may be stored in a non-volatile computer readable storage medium executable by a processor. Based on such understanding, the technical solutions of the present application may be embodied in essence or a part contributing to the prior art or a part of the technical solutions, or in the form of a software product, which is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the methods described in the embodiments of the present application. And the aforementioned storage medium includes: a U-disk, a removable hard disk, a Read-Only Memory (ROM), a random access Memory (Random Access Memory, RAM), a magnetic disk, or an optical disk, or other various media capable of storing program codes.
The foregoing is merely a specific embodiment of the present application, but the protection scope of the present application is not limited thereto, and any person skilled in the art can easily think about changes or substitutions within the technical scope of the present application, and the changes or substitutions are covered in the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the protection scope of the claims.
Claims (12)
1. A method of service processing, the method comprising:
generating a corresponding first target transaction and a message to be consumed according to the received service request, wherein a starting annotation is added to the first target transaction and is used for realizing the quick starting of the first target transaction through a software development tool;
executing the first target transaction and acquiring a first submitting result of the first target transaction;
judging whether the first commit result is that the first target transaction is committed;
if the first commit result is that the first target transaction is committed, the message to be consumed is sent to a message middleware, the first target transaction committed indicates that the first business processing logic and the first persistence processing logic encapsulated in the first target transaction are executed successfully at the same time, the first business processing logic is an operation which is determined according to a business request and is executed on a first database, and the first persistence processing logic is used for carrying out persistence processing on the message to be consumed in the first database;
the method comprises the steps that first business processing logic and first persistence processing logic are packaged into a first target transaction through packaging logic in a preloaded software development kit;
after the step of sending the message to be consumed to message middleware, the method further comprises:
and extracting the message to be consumed from the message middleware, generating a second target transaction according to the message to be consumed, completing the processing of the service request through the second target transaction, and encapsulating by second service processing logic and second persistence processing logic aiming at a second database to form a second target object.
2. The method of claim 1, wherein after the step of sending the message to be consumed to message middleware, the method further comprises:
executing a second target transaction, and acquiring a second submitting result corresponding to the second target transaction;
and according to the second submitting result, finishing the processing of the service request.
3. The method of claim 1, wherein generating the corresponding first target transaction from the received service request comprises:
determining a first service processing logic and a first persistence processing logic for a first database according to the received service request;
and packaging the first business processing logic and the first persistence processing logic aiming at the message to be consumed into a first target transaction.
4. The method of claim 3, wherein the step of encapsulating the first business processing logic and the first persistence processing logic for the message to be consumed as a first target transaction comprises:
adding the same transaction identifier to the first business processing logic and the first persistence processing logic aiming at the message to be consumed through a preset software development kit;
and forming a first target transaction by the first business processing logic and the first persistence processing logic after adding the same object identifier.
5. The method of claim 1, wherein after the step of determining whether the first commit result is that the first target transaction has committed, the method further comprises:
and if the first commit result is that the first target transaction is not committed, controlling the first database of the first persistence processing logic operation to be restored to a state before the first target transaction is committed, wherein the first target transaction is not committed and indicates that the first business processing logic and/or the first persistence processing logic fails to execute.
6. The method according to claim 1, wherein the method further comprises:
generating a receiving state aiming at the message to be consumed according to the received message to be consumed;
feeding back the receiving state to the sending end of the message to be consumed;
and updating the sending state of the message to be consumed according to the receiving state.
7. The method of claim 6, wherein the receipt status includes message receipt success and message receipt failure, the method further comprising:
if the receiving state is successful in message receiving, the sending end updates the sending state of the message to be consumed from a pre-sending state to a sent state;
if the receiving state is not received by the transmitting end or the receiving state is message receiving failure, the transmitting end resends the message until the receiving state is message receiving success, and the transmitting state of the message to be consumed is updated from a pre-transmitting state to a transmitted state.
8. The method of claim 1, wherein the step of determining a second target transaction from the message to be consumed comprises:
determining second business processing logic and second persistence processing logic aiming at a second database according to the received message to be consumed, wherein the second persistence processing logic is used for carrying out persistence processing on the message to be consumed in the second database;
and packaging the second business processing logic and the second persistence processing logic into a second target transaction.
9. The method of claim 2, wherein the step of completing processing of the service request based on the second submission result further comprises:
determining the current consumption progress of the message to be consumed according to the second submitting result;
and according to the current consumption progress, finishing the processing of the service request.
10. The method of claim 9, wherein the step of determining the current consumption progress for the message to be consumed based on the second submission result comprises:
judging whether the second commit result is that the second target transaction is committed;
if the second submitting result is that the second target transaction is submitted, submitting the consumption progress to a second database, wherein the second target transaction is submitted to indicate that the second business processing logic and the second persistence processing logic are successfully executed at the same time;
updating the current consumption progress of the message to be consumed in the second database;
if the second commit result is that the second target transaction is not committed, controlling second business processing logic and second persistence processing logic in the second target transaction to automatically roll back, wherein the second target transaction is not committed and indicates that the execution of the second business processing logic and/or the second persistence processing logic fails;
obtaining a persistence result corresponding to the second persistence processing logic;
and determining the current consumption progress aiming at the message to be consumed according to the persistence result corresponding to the second persistence processing logic.
11. The method of claim 10, wherein the step of determining the current consumption progress for the message to be consumed based on the persistence result corresponding to the second persistence processing logic comprises:
if the persistence result indicates that the message to be consumed has been stored to the second database, then:
submitting a consumption schedule to the second database;
determining the current consumption progress of the message to be consumed in the second database;
if the persistence result indicates that the message to be consumed is not stored in the second database, then:
restoring the second database to a second target transaction pre-execution state;
and consuming the message to be consumed again to acquire the current consumption progress.
12. A service processing apparatus, characterized in that the service processing apparatus comprises:
the business request receiving module is used for generating a corresponding first target transaction and a message to be consumed according to the received business request, and a starting annotation is added to the first target transaction and used for realizing the quick starting of the first target transaction through a software development tool;
the first execution module is used for executing the first target transaction and acquiring a first submitting result of the first target transaction;
the judging module is used for judging whether the first submitting result is that the first target transaction is submitted or not;
the sending module is used for sending the message to be consumed to a message middleware if the first submitting result is that a first target transaction is submitted, wherein the first target transaction is submitted to indicate that the first business processing logic and the first persistence processing logic encapsulated in the first target transaction are executed successfully at the same time, the first business processing logic is an operation which is determined according to a business request and is executed on a first database, and the first persistence processing logic is used for carrying out persistence processing on the message to be consumed in the first database;
wherein, the sending module is further used for:
packaging the first business processing logic and the first persistence processing logic into a first target transaction through packaging logic in a preloaded software development kit;
the device also comprises an extraction module for extracting the message to be consumed from the message middleware, generating a second target transaction according to the message to be consumed, completing the processing of the service request through the second target transaction, and forming a second target object by packaging second service processing logic and second persistence processing logic aiming at a second database.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202210837295.2A CN115220877B (en) | 2022-07-15 | 2022-07-15 | Service processing method and device |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202210837295.2A CN115220877B (en) | 2022-07-15 | 2022-07-15 | Service processing method and device |
Publications (2)
Publication Number | Publication Date |
---|---|
CN115220877A CN115220877A (en) | 2022-10-21 |
CN115220877B true CN115220877B (en) | 2023-06-13 |
Family
ID=83612786
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202210837295.2A Active CN115220877B (en) | 2022-07-15 | 2022-07-15 | Service processing method and device |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN115220877B (en) |
Citations (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101145165A (en) * | 2007-10-30 | 2008-03-19 | 金蝶软件(中国)有限公司 | Work stream data persistence processing method, device and work flow system |
CN110990182A (en) * | 2019-12-03 | 2020-04-10 | 腾讯科技(深圳)有限公司 | Transaction processing method, device, equipment and storage medium |
Family Cites Families (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US8650155B2 (en) * | 2008-02-26 | 2014-02-11 | Oracle International Corporation | Apparatus and method for log based replication of distributed transactions using globally acknowledged commits |
US8751437B2 (en) * | 2012-11-01 | 2014-06-10 | Sap Ag | Single persistence implementation of business objects |
CN108009027B (en) * | 2017-11-23 | 2019-09-20 | 北京百度网讯科技有限公司 | Implementation method, device, equipment and the storage medium of queue message consistency |
-
2022
- 2022-07-15 CN CN202210837295.2A patent/CN115220877B/en active Active
Patent Citations (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101145165A (en) * | 2007-10-30 | 2008-03-19 | 金蝶软件(中国)有限公司 | Work stream data persistence processing method, device and work flow system |
CN110990182A (en) * | 2019-12-03 | 2020-04-10 | 腾讯科技(深圳)有限公司 | Transaction processing method, device, equipment and storage medium |
Also Published As
Publication number | Publication date |
---|---|
CN115220877A (en) | 2022-10-21 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US9137180B2 (en) | Method for data delivery in a network | |
CN111666162A (en) | Distributed message transmission method, device, computer equipment and storage medium | |
CN109756508B (en) | Message proxy method based on multi-protocol access block chain network and related equipment | |
CA3158476C (en) | Method for processing response timeout, and systems for server and client to process response timeout | |
CN111666745B (en) | File downloading method, device, server and medium | |
CN112181677B (en) | Service processing method and device, storage medium and electronic device | |
CN111522697A (en) | Restarting processing method of block chain consensus node, consensus node and block chain system | |
CN107679844A (en) | The method, apparatus and storage medium of resource transfers | |
CN112995262B (en) | Distributed transaction submission method, system and computing equipment | |
CN115220877B (en) | Service processing method and device | |
CN110941622A (en) | Data processing method and device | |
CN112114938A (en) | Transaction processing method and device and server | |
CN109905459B (en) | Data transmission method and device | |
CN117762652A (en) | Distributed transaction processing method and device based on message middleware | |
CN113342541A (en) | Message consumption method and device, computing equipment and storage medium | |
CN115811538B (en) | Method, device, system and medium for requesting and processing digital key service | |
CN109600722B (en) | Short message receiving verification method and device, electronic equipment and storage medium | |
CN112702371B (en) | Message sending method and device and intelligent terminal | |
CN112379952B (en) | Method for implementing cross-process callback | |
CN113452603A (en) | Data transmission method and related device | |
CN110677465B (en) | Control method and device of distributed lock | |
CN110471739B (en) | Instruction retry method and device | |
CN113377385A (en) | Client automatic deployment method and device | |
CN113434307A (en) | Task sending processing method, task processing method, device, system and equipment | |
CN112130783B (en) | File printing 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 |