A method, device, equipment and service system for starting a workflow instance
Patent Information
- Application Number
- CN202411553998.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-01
- Publication Date
- 2026-09-18
- Estimated Expiration
- 2044-11-01
AI Technical Summary
[0005]本发明提供一种工作流实例的启动、装置、设备及服务系统,以解决工作流中多业务场景需要走相同的审批流程时,逐个添加新的审批业务,以及改写审批接口的服务代码,导致实际业务耗时较长、连接超时以及出现的性能问题
[0052] This invention provides a method, apparatus, device, and service system for starting a workflow instance. The system starts the workflow instance on the business server and sends an approval business request to a message queue. The message queue then forwards this approval request to the workflow server, enabling the workflow server to quickly initiate the approval process. This reduces potential delays in traditional methods and improves the timeliness of business processing. Furthermore, the method clearly defines the subject to be monitored, the business ID, and the workflow instance type, making the initiation of the approval process more precise and efficient. Moreover, by using workflow-driven mechanisms, the workflow approval process is decoupled from the associated actual business processing, ensuring that changes to one side's code do not affect the other, reducing code processing time and improving the efficiency of workflow instance startup and approval.
Smart Images

Figure CN119415180B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of computer technology, and more specifically to a workflow instance initiation, apparatus, device, and service system. Background Technology
[0002] With the development of computer technology, more and more business approval processes are being transferred to company management systems. To facilitate business process management in enterprise applications and ensure its flexibility, scalability, and automation, the concept of a workflow management system has been proposed and applied to various fields.
[0003] With the emergence of microservices technology, considering that multiple business processes need to design related workflow management processes, workflows are usually deployed as independent service units. When other business processes require approval or other process management, they will call the workflow service remotely from the relevant service of this business and execute the specific workflow nodes in a predefined order.
[0004] The workflow involves multiple services. For example, Service A is the deployed workflow service, developed using the Activiti workflow engine in Java. Services B, C, and D are other services that need to call Service A. These services are developed by different teams using different programming languages, but each service has one or more business scenarios that require the same approval process. In this case, each approval process needs to be designed, consuming resources and increasing costs. Furthermore, after each node in the workflow is completed, the related services in Service B / C / D need to handle additional logic specific to that business. Additionally, when a new approval business needs to be added, the service code for the unified approval interface must be rewritten, again failing to achieve code decoupling. Summary of the Invention
[0005] This invention provides a workflow instance startup, device, equipment, and service system to solve the problems of adding new approval processes one by one and rewriting the service code of the approval interface when multiple business scenarios in a workflow need to follow the same approval process, resulting in long actual business processing time, connection timeouts, and other performance issues.
[0006] In a first aspect, the present invention provides a method for starting a workflow instance, applied to a first business server, the method comprising:
[0007] Initiate and send an approval business request to the message queue. The approval business request is used to start the approval process and inform the service of at least one of the following: the topic to be listened to, the associated business ID, and the type of the workflow instance to be started. The approval process is at least the same as the approval process of the second business service.
[0008] According to the preset association, the response messages fed back by the workflow service are monitored in real time in the message queue, wherein the preset association includes the correspondence between each type of business and a topic;
[0009] When the target response message corresponding to the approval business request is detected, the target response message is parsed. The target response message is generated based on at least the topic, the business ID, and the workflow instance type.
[0010] Based on the content of the target response message, it is determined that the workflow instance corresponding to the approval business request has been successfully started, and the approval operations of each node in the workflow instance are executed according to the workflow instance.
[0011] In conjunction with the first aspect, in one possible implementation, before initiating and sending the approval service request to the message queue, the method further includes: establishing the preset association relationship; establishing the preset association relationship includes:
[0012] Establish the association between the workflow service and the shared topic in the message queue, and,
[0013] Establish at least one association relationship for at least one business service, each of the association relationships being a one-to-one correspondence between the business service and the listening topic in the message queue, wherein the at least one business service includes the first business service;
[0014] The parsing of the target response message includes:
[0015] Parse the target response message to obtain at least one of the following: the business ID to be associated with the workflow instance of the approval process, the business-associated instance keyword, the unique identifier of the workflow instance, and the start-up success indication field;
[0016] The step of determining that the workflow instance corresponding to the approval business request has started successfully based on the content of the target response message includes: if the content obtained after parsing the target response message contains the indication field of successful startup, then the corresponding workflow instance is determined to have started successfully.
[0017] In conjunction with the first aspect, in another possible implementation, each node in the workflow instance includes an application node, and the method further includes:
[0018] When the content obtained by parsing the target response message indicates that the application node in the workflow instance has been completed, the data table associated with the current instance is searched according to the instance keyword associated with the business.
[0019] Update the unique identifier of the workflow instance to the entry in the data table whose ID value is the first value.
[0020] In conjunction with the first aspect, in another possible implementation, the step of performing the approval operations at each node of the workflow instance includes:
[0021] The message queue receives a notification message after the workflow service has approved the current node. The notification message includes: an indication field indicating whether the approval has passed, as well as the identifier of the current node and the unique identifier of the workflow instance.
[0022] According to the notification message, if the indication field indicates approval, the workflow operation of the current node is executed based on the identifier of the current node.
[0023] Secondly, the present invention provides a method for starting a workflow instance, applied to a workflow server, wherein the workflow server has the functions of workflow execution and providing a common approval interface for at least one business server, the method comprising:
[0024] Listen for approval requests sent by the first business service through a message queue. The approval request includes at least one of the following: the topic to be listened to by the first business service, the associated business ID, and the type of workflow instance to be started. The approval process is at least the same as the approval process of the second business service.
[0025] Parse the approval request, create a workflow instance based on the content of the approval request, and generate a target response message indicating that the workflow instance has started successfully;
[0026] The target response message is sent to a message queue according to a preset association relationship, so that the first business service can listen to and obtain the target response message in the message queue. The preset association relationship includes the correspondence between the first business service and the topic to be listened to by the first business service.
[0027] In conjunction with the second aspect, in one possible implementation, the step of creating a workflow instance based on the content of the approval business request and generating a target response message indicating that the workflow instance has started successfully includes:
[0028] Based on the content of the approval request, prepare to start the workflow instance;
[0029] Once the workflow instance starts successfully, a unique identifier for the workflow instance and a success indication field are generated.
[0030] The target response message is generated based on at least one of the following: the business ID to be associated with the workflow instance, the instance keyword associated with the business, the unique identifier, and the start-up success indication field.
[0031] In conjunction with the second aspect, in another possible implementation, after the workflow instance is successfully started, it further includes:
[0032] The general approval entry defined in the workflow service is invoked to approve each node in the workflow instance and generate a notification message corresponding to the approval of the current node. The notification message includes: an indication field indicating whether the approval is passed, as well as the identifier of the current node and the unique identifier of the workflow instance.
[0033] The notification message is added to the message queue so that the corresponding business service can listen for and retrieve the notification message in the message queue.
[0034] In conjunction with the second aspect, in yet another possible implementation, the method further includes:
[0035] Using Activiti as the process execution framework, a corresponding workflow instance is created and started based on at least one approval business request from at least one business server. The system also listens to, parses, and records the data in the message queue, and sends response messages and / or notification messages to the message queue.
[0036] Thirdly, the present invention also provides a workflow instance initiation device, applicable to any business server, the device comprising:
[0037] The first sending module is used to send an approval business request to the message queue. The approval business request is used to start the approval process and to inform the service of at least one of the following: the topic to be listened to, the associated business ID, and the type of workflow instance to be started. The approval process is at least the same as the approval process of the second business service.
[0038] The first listening module is used to listen to the response messages fed back by the workflow service in real time in the message queue according to the preset association relationship, wherein the preset association relationship includes the correspondence between each type of business and a topic;
[0039] The parsing module is used to parse the target response message when the target response message corresponding to the approval business request is detected. The target response message is generated based at least on the topic, the business ID and the workflow instance type.
[0040] The determination module is used to determine, based on the content of the target response message, that the workflow instance corresponding to the approval business request has been successfully started, and to execute the approval operations of each node in the workflow instance.
[0041] Fourthly, the present invention also provides a workflow instance initiation device, applied to a workflow server, the device comprising:
[0042] The second listening module is used to listen for approval business requests sent by the first business service through a message queue. The approval business request includes at least one of the following: the topic to be listened to by the first business service, the associated business ID, and the type of workflow instance to be started. The approval process is at least the same as the approval process of the second business service.
[0043] The processing module is used to parse the approval business request, create a workflow instance based on the content of the approval business request, and generate a target response message indicating that the workflow instance has started successfully.
[0044] The second sending module is used to send the target response message to a message queue according to a preset association relationship, so that the first business service can listen to and obtain the target response message in the message queue. The preset association relationship includes the correspondence between the first business service and the topic it wants to listen to.
[0045] Fifthly, the present invention provides an electronic device, comprising: a memory and a processor, wherein the memory and the processor are communicatively connected to each other, the memory stores computer instructions, and the processor executes the computer instructions to perform the workflow instance startup method described in any embodiment corresponding to the first or second aspect above.
[0046] In a sixth aspect, the present invention provides a computer-readable storage medium storing computer instructions for causing a computer to execute the startup method of a workflow instance as described in any embodiment corresponding to the first or second aspect above.
[0047] Furthermore, the present invention provides a computer program product, including computer instructions for causing a computer to execute a startup method for a workflow instance as described in any embodiment corresponding to the first or second aspect above.
[0048] In a seventh aspect, the present invention provides a service system, the system comprising: at least one business server, a workflow server, and a message queue, wherein the workflow server provides a public approval interface for at least one business server;
[0049] The message queue is used to send and receive request, data, or notification messages between each business server and the workflow server.
[0050] A business server is used to execute the startup method of the workflow instance described in the first aspect or any of its corresponding embodiments;
[0051] A workflow server is used to execute the startup method of the workflow instance described in the second aspect or any of its corresponding embodiments.
[0052] This invention provides a method, apparatus, device, and service system for starting a workflow instance. The system starts the workflow instance on the business server and sends an approval business request to a message queue. The message queue then forwards this approval request to the workflow server, enabling the workflow server to quickly initiate the approval process. This reduces potential delays in traditional methods and improves the timeliness of business processing. Furthermore, the method clearly defines the subject to be monitored, the business ID, and the workflow instance type, making the initiation of the approval process more precise and efficient. Moreover, by using workflow-driven mechanisms, the workflow approval process is decoupled from the associated actual business processing, ensuring that changes to one side's code do not affect the other, reducing code processing time and improving the efficiency of workflow instance startup and approval.
[0053] Furthermore, when multiple business services have the same approval process, this method uses a workflow service as a unified interface for the approval process, providing a common approval interface for business services with the same approval process. This avoids adding new approval processes to each service with the same approval process, reducing the interface development process and improving development efficiency. Attached Figure Description
[0054] To more clearly illustrate the specific embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the specific embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present invention. For those skilled in the art, other drawings can be obtained from these drawings without creative effort.
[0055] Figure 1 This is a flowchart of a workflow instance startup method according to an embodiment of the present invention;
[0056] Figure 2 This is a schematic diagram of a general approval process according to an embodiment of the present invention;
[0057] Figure 3 This is a flowchart of another workflow instance startup method according to an embodiment of the present invention;
[0058] Figure 4This is a flowchart of another workflow instance startup method according to an embodiment of the present invention;
[0059] Figure 5 This is a signaling diagram of data flow between a workflow service and an actual business service according to an embodiment of the present invention;
[0060] Figure 6 This is a schematic diagram illustrating the data flow between a workflow service and an actual business service according to an embodiment of the present invention;
[0061] Figure 7 This is a structural block diagram of a starting device according to an embodiment of the present invention;
[0062] Figure 8 This is a structural block diagram of another starting device according to an embodiment of the present invention;
[0063] Figure 9 This is a schematic diagram of the hardware structure of an electronic device according to an embodiment of the present invention. Detailed Implementation
[0064] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0065] In the description of this invention, it should be noted that, unless otherwise explicitly specified and limited, the terms "installation," "connection," and "linking" should be interpreted broadly. For example, they can refer to a fixed connection, a detachable connection, or an integral connection; they can refer to a mechanical connection or an electrical connection; they can refer to a direct connection or an indirect connection through an intermediate medium; and they can refer to the internal connection of two components. Those skilled in the art can understand the specific meaning of the above terms in this invention according to the specific circumstances.
[0066] Furthermore, the terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance.
[0067] The technical features involved in the different embodiments of the present invention described below can be combined with each other as long as they do not conflict with each other.
[0068] First, the application scenarios and related technical terms involved in the technical solution of this invention will be introduced.
[0069] (1) Microservices
[0070] Microservices refer to numerous loosely coupled, independently deployable small components or services within a single application. These services typically have their own technology stack, including databases and data management models; they communicate with each other through a combination of REST APIs, event streams, and message brokers; and they are organized according to business capabilities.
[0071] REST API (Representational State Transfer, Application Programming Interface) is a design style and development approach for web applications that allows different software applications to communicate and exchange data over a network. REST API is based on the HTTP protocol and uses standard HTTP methods (such as GET, POST, PUT, DELETE, etc.) to perform operations on resources.
[0072] (2) Workflow and Workflow Examples
[0073] Workflow is the automated execution and management of business processes through computers, enabling multiple participants to automatically exchange documents, information, or tasks according to certain predefined rules.
[0074] A workflow instance is a term in computer science that refers to an actual execution of a workflow according to a given workflow pattern. A workflow instance is the concrete manifestation of a workflow definition after it has been run; a single workflow definition can generate multiple workflow instances. These instances represent the specific application and execution of the workflow in a real-world business environment.
[0075] Specifically, a workflow instance can consist of multiple stages (or activities, nodes, tasks), which are arranged in a certain order and executed sequentially. Each stage has a specific function and responsibility, working together to achieve the overall goal of the workflow. Furthermore, workflow instances have wide applications in multiple fields, including but not limited to:
[0076] Business process management: such as approval processes, order processing processes, expense reimbursement processes, etc. By defining process models, rules, and conditions, the execution and monitoring of processes can be automated.
[0077] Work order processing: such as service requests, fault handling, and customer complaints. The workflow engine allows for the dispatching of work orders, tracking of their processing progress, and prioritization and allocation.
[0078] Resource scheduling and task allocation: such as allocating server resources, scheduling task execution order and priority, etc. By defining workflow models and task dependencies, tasks can be scheduled and allocated automatically.
[0079] Event-driven processes: such as real-time data processing, message queue processing, and event-triggered business processes. By listening to and responding to events, real-time process control and data processing can be achieved.
[0080] E-commerce processes, such as order processing, inventory management, and payment processes, can be automated and optimized by defining process models and business rules.
[0081] (3) Activiti
[0082] Activiti is a workflow parsing engine that can extract complex business processes from a business system, define them using a specialized modeling language, and allow the business system to execute according to the predefined processes. This reduces the workload of upgrading and modifying the business system due to process changes, thereby improving the system's robustness and reducing system development and maintenance costs.
[0083] (4) Kafka
[0084] Kafka is an open-source distributed event streaming platform, which can also be viewed as a distributed message queue based on the publish / subscribe pattern, used to process all real-time messages from consumers and producers.
[0085] Kafka's core functionalities include message queuing, stream processing, data storage, and distributed system integration. The message queuing function allows Kafka to pass messages between different applications, enabling decoupled asynchronous communication. Producers send messages to a Kafka cluster, and consumers read messages from it.
[0086] Data stream processing capabilities refer to Kafka's support for real-time data processing and analysis. Through tools such as Kafka Streams and KSQL, messages can be streamed and transformed. Furthermore, Kafka supports persistent messages, data backup and recovery, allowing data to be written to Kafka and periodically backed up to other storage systems.
[0087] Optionally, the Kafka in this embodiment of the invention can be Apache Kafka, which is an open-source distributed stream processing platform.
[0088] (5) RPC
[0089] Remote Procedure Call (RPC) is a protocol that allows a program on one computer to call a program or service on another computer, just as if it were a local service, without requiring the programmer to perform complex programming of this interaction.
[0090] How it works: RPC uses a client / server model. The calling program (client) sends a call message with process parameters to the server program (server) and then waits for a response. After receiving the call message, the server calculates the result and sends a response message back to the client. After receiving the response message, the client continues execution.
[0091] The application scenarios and technical problems arising from the embodiments of the present invention will be described below.
[0092] Common methods for service calls between microservices include HTTP (Hypertext Transfer Protocol) / HTTPS (Hypertext Transfer Protocol Secure) calls or Remote Procedure Calls (RPC).
[0093] HTTP / HTTPS is a simple and universal microservice calling method. However, the current approval methods for all businesses are not uniform in the front-end interface. After the approval plan is submitted on the front end, the associated actual business is notified to perform its business work. This needs to be done synchronously. When the actual business takes a long time, it can easily lead to connection timeouts. When there are many approval businesses, performance issues may also occur.
[0094] While RPC enables cross-programming language communication between microservices, it requires writing different implementations for different languages, making the implementation process rather cumbersome. Furthermore, when adding a new approval function, the service code for the unified approval interface must be rewritten, again failing to achieve code decoupling. For example, when service B needs to call service A using HTTP, the execution time of service A should not be too long; otherwise, service B might time out while waiting for service A to finish, causing service B to fail as well.
[0095] The technical solutions provided in the embodiments of the present invention aim to solve the following problems or achieve the following beneficial effects:
[0096] 1. Decouple workflow approval from the associated actual business code. Workflow call code will not be involved in the business code, and the common interfaces of workflow-related nodes will not call the actual business code. The actual business-related services and the service to which the workflow belongs communicate only through message queues.
[0097] 2. Enable the Activiti workflow service written in Java to be called by other languages without requiring additional code modifications. Communicate between services via message queues, eliminating direct calls between services and achieving cross-programming language communication.
[0098] For example, if business services A / B / C / D are all developed using Spring Cloud, service B can directly call service A using OpenFeign, a simplified HTTP call method. However, if service B is developed using Go and service C is developed using Rust, calling service A (developed in Java) using HTTP methods would be problematic. Since the implementation of HTTP methods differs across languages / programs, services cannot directly call each other and require separate service code for each interface.
[0099] 3. Enable the sharing of identical approval workflow code across multiple business processes. When the same approval process needs to be embedded in multiple business processes, it is desirable to write only one set of code for the approval process. In actual business calls (where the workflow approval process of this node and the business code execution process of related nodes need to be executed simultaneously), only the code for the actual business needs to be handled separately, without having to handle the code related to the approval process again.
[0100] 4. Use the same front-end entry point for approval operations of workflows with the same workflow approval model. When services B / C / D use the same workflow model, the workflow nodes can be executed through a unified workflow approval entry point. After the workflow service is completed, a node completion notification is sent to the specific service (B, C, or D service) where the related business is located to inform the actual business to carry out other follow-up work.
[0101] The technical solution disclosed herein uses microservices as its architectural foundation and message queues for inter-service communication and invocation, providing a loosely coupled and scalable approach to inter-service calls. The use of asynchronous communication ensures the reliability and stability of inter-service calls even when there are many workflow instances or when business processes take a long time to execute.
[0102] In addition, inter-service communication is achieved through message queues, enabling the execution of workflow services to drive the flow of specific business service processes associated with them, while ensuring the decoupling of workflow approval processes and business process processing.
[0103] This invention provides an embodiment of a method for starting a workflow instance. It should be noted that the steps shown in the flowchart in the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions. Furthermore, although a logical order is shown in the flowchart, in some cases, the steps shown or described may be executed in a different order than that shown here.
[0104] This embodiment provides a method for starting a workflow instance, which can be used by any business server, such as the first business server. The first business server is a server, such as business service B, service C, or service D. The end requesting approval is called the "workflow server", or simply the workflow service, such as service A.
[0105] Figure 1 This is a flowchart of a startup method according to an embodiment of the present invention, such as... Figure 1 As shown, the process includes the following steps:
[0106] Step S101: Start and send an approval request to the message queue.
[0107] The approval business request is used to initiate the approval process and to inform the service of at least one of the following: the topic to be monitored, the associated business ID, and the type of workflow instance to be initiated. The approval process is at least the same as the approval process of the second business service (e.g., service C or service D).
[0108] Specifically, the business service sends a request to initiate the approval process to the message queue, specifying the topic to be listened to in subsequent responses. Each type of business listens to a specific topic, and all responses related to this business from the subsequent workflow service are sent to that topic. Specifying a topic means that the business process informs the message queue that all responses related to this business from the subsequent workflow service will be sent to the designated topic.
[0109] Message queue processing: After receiving a request to initiate an approval process, the message queue stores it. Workflow service listening: The workflow service (e.g., service A) listens to a specified topic to retrieve request messages related to this business.
[0110] The approval process refers to the general approval process for a project, such as... Figure 2 The diagram illustrates a typical approval process, which includes four stages: application, project manager approval, department manager approval, and general manager approval. The execution order of these four stages is as follows: Figure 2 As shown, each node can proceed to the next approval step after being approved by the "manager" (a general term referring to the three managers), until the final node, the general manager, approves it, at which point the approval process ends. If any node's approval is rejected, the process returns to the initial node, as shown below. Figure 2 As shown, the initial node is the "applyNode".
[0111] It should be understood that the approval process in this embodiment includes, but is not limited to, Figure 2The process shown can also consist of more or fewer nodes, and this embodiment does not impose any limitations on this. Furthermore, the approval process described is one application scenario of a workflow instance, and this approval process includes, but is not limited to, personnel approval processes, engineering project approvals, operational process approvals, etc. The specific content and areas involved in the approval process in this embodiment are not limited.
[0112] Optionally, the message queue can be Kafka or Apache Kafka, or a software module with Kafka functionality. Further details regarding Kafka functionality are described in the foregoing embodiments and will not be repeated here.
[0113] In addition, the process of initiating the approval request in this step can be initiated by the current business node itself, or by the user when the front-end workflow starts. Correspondingly, there can be multiple initiating users, and there can also be multiple corresponding service businesses. For example, services B, C, and D can be initiated by different users simultaneously or sequentially, requesting the creation of a workflow instance from their common approval process end.
[0114] Step S102: Based on the preset association, listen for response messages from the workflow service in real time in the message queue.
[0115] The preset associations include the correspondence between each type of business and a topic.
[0116] Specifically, such as Figure 3 As shown, before initiating and sending the approval request to the message queue, the following steps are also included:
[0117] Step S100: Establish a preset association relationship. Further, step S100 specifically includes:
[0118] Step S100-1: Establish the association between the workflow service and the shared topic in the message queue.
[0119] The workflow service is an end module with workflow execution and workflow parsing engine functions, such as workflow service A, or simply "service A". The relationship is the correspondence between service A and topics, such as topic-a. This can be understood as follows: messages and data listened to in the message queue through topic-a are uniformly transmitted to service A.
[0120] Step S100-2: Establish at least one association relationship for at least one business service.
[0121] Each relationship is a one-to-one correspondence between a business service and a listening topic in the message queue, and at least one business service includes the first business service.
[0122] For example, services B, C, and D are all business servers. Each service (B, C, and D) contains a business transaction requiring approval. For instance, the transaction awaiting approval in service B might be BB, in service C it might be CB, and in service D it might be DB. The approval processes for these three transactions (BB, CB, and DB) share the same Activiti approval model, such as using a common appendix. Figure 2 The approval process.
[0123] At the same time, after each business BB, CB, and DB completes each approval node, some other operations need to be handled separately. For example, when executing the project manager approval node, after the workflow of service A completes the node, the node still needs to continue to execute the business specific to BB in the PB business. Only when both businesses are completed can the node be considered to have completed.
[0124] Message queues, such as Kafka, are responsible for receiving and sending messages, requests, data, and notifications from services A through D. They also establish associations between different topics and business logic. In this embodiment, it is assumed that services B, C, and D are associated with topics-b,-c, and-d respectively in Kafka, meaning that services B, C, and D listen to messages in Kafka on topics named topic-b, topic-c, and topic-d, respectively. These topic messages include, but are not limited to, approval requests. These topic messages have been correctly created and stored before the approval process is initiated.
[0125] Similarly, in step S100-1: Service A will listen for Topic messages named topic-a in Kafka, which are used to start workflow instances.
[0126] Step S103: When the target response message corresponding to the approval business request is detected, parse the target response message.
[0127] The target response message is generated by a workflow service, such as service A, based at least on the topic, business ID, and workflow instance type in the aforementioned request. In this embodiment, the response based on the approval business request is referred to as the target response message.
[0128] Specifically, service A will call the Kafka connection-related code to send information related to the creation of the approval instance to topic-a of the Kafka service. This information includes the following:
[0129] ① The type of workflow instance to be created in this business (processType);
[0130] ② The topic to be listened to when receiving feedback information in the later stages of this service. For example, assuming the requested service is service B, then a topic-b is created and associated with a service BB in service B;
[0131] ③ The business ID that the approval process instance needs to be associated with;
[0132] ④ The instance key (businessKey) associated with the current business, used to determine which table to look up the business ID in after receiving feedback information. For example, the instance key associated with business BB.
[0133] ⑤ The names or identifiers of the project manager (project User), the department manager (department User), and the general manager (general User) who need approval.
[0134] The above-mentioned information can be configured and generated by the business server.
[0135] like Figure 3 As shown, one possible implementation of this step is: Step S103-1: Parse the target response message to obtain at least one of the following fields: business ID (businessId), business-associated instance key (businessKey), unique identifier of the workflow instance (instanceId), and start-up success indication field.
[0136] In addition, parsing the target response message can yield other information besides those mentioned in ① to ⑤ above.
[0137] Step S104: Based on the content of the target response message, determine that the workflow instance corresponding to the approval business request has started successfully, and execute the approval operations of each node in the workflow instance.
[0138] Specifically, one implementation includes:
[0139] Step S104-1: If the content obtained after parsing the target response message contains an indication field indicating successful startup, then the corresponding workflow instance is determined to have started successfully.
[0140] Step S104-2: Perform the approval operations for each node in the workflow example.
[0141] Specifically, the approval operations of each node in the workflow instance are executed, including: receiving a notification message from the workflow service (A) after the current node has been approved in the message queue. The notification message includes: an indication field indicating whether the approval has passed, as well as the identifier of the current node and the unique identifier (instanceId) of the workflow instance; and, based on the notification message, if the indication field indicates that the approval has passed, executing the workflow operation of the current node based on the identifier of the current node.
[0142] In this embodiment, after parsing the target response message to obtain its content, step S104 of the above method further includes:
[0143] If the application node in the workflow instance has been completed, search the data table associated with the current instance based on the instance keyword related to the business; update the unique identifier of the workflow instance to the entry in the data table whose ID value is the first value.
[0144] The workflow service continuously listens to a specific topic, and when a startup request is sent to that topic, the workflow service will receive the request.
[0145] The workflow parsing engine parses and records relevant data: After receiving a start request, the workflow parsing engine parses the request, extracts the relevant data, and records it. This data may include business process information, start parameters, etc.
[0146] The specific implementation process of the workflow parsing engine starting a workflow instance includes: based on the parsed content (step S103-1 above), the workflow parsing engine starts a workflow instance. A workflow instance is the specific execution process of a workflow, containing a series of tasks and steps. After successful instance startup, the workflow instance ID and other relevant information are fed back to the specific business service: once the workflow instance starts successfully, the workflow parsing engine sends the workflow instance ID and other relevant information to the specific business service. This information is then sent to the topic that the business service is listening to.
[0147] In this way, workflow services and specific business services can interact. The workflow service is responsible for starting and managing workflow instances and feeding back relevant information to the business services, which can then perform subsequent processing and operations based on this information. This message queue-based communication method helps to achieve decoupling and flexibility in the system, allowing different services to be developed and deployed independently, while enabling effective collaboration and data exchange through message queues.
[0148] See Figure 4This is another method for starting a workflow instance provided in this embodiment. This method can be applied to a workflow server, which has the functions of workflow execution and providing a public approval interface for at least one business server.
[0149] like Figure 4 As shown, the method includes:
[0150] Step S201: Listen for approval requests sent by the first business service through the message queue.
[0151] This step S201 corresponds to step S101 in the aforementioned embodiment. The approval business request includes at least one of the following: the topic to be monitored by the first business service, the associated business ID, and the type of workflow instance to be started. Furthermore, the approval process is at least the same as the approval process of the second business service. For example, the first business service is business B, the second business service is business C, and business B and business C include the same approval process. Figure 2 The approval process is shown below.
[0152] Workflow service A continuously listens to a specific topic. When an approval request is sent to that topic from the message queue, workflow service A will receive the request.
[0153] Step S202: Parse the approval business request, create a workflow instance based on the content of the approval business request, and generate a target response message indicating that the workflow instance has started successfully.
[0154] After receiving an approval request, the workflow parsing engine parses the request, extracts relevant data, and records it. This data may include business process information, startup parameters, etc.
[0155] Workflow service A listens for approval requests from service B in real time through the pre-defined association in the message queue, namely the correspondence between service A in step S100-1 and topic-a. The message queue forwards the approval requests from service B to service A.
[0156] Workflow service A parses the approval request and obtains the relevant information from ① to ⑤ above. Based on this information, i.e., the content of the approval request, it prepares to start the workflow instance. Once the workflow instance starts successfully, it generates a unique identifier (instanceId) and a success indication field. This indication field (instanceId) is a newly added field used to uniquely identify the current workflow instance.
[0157] Based on the parsed information, workflow service A's workflow parsing engine will launch a workflow instance. A workflow instance is the specific execution process of the workflow, containing a series of tasks and steps, such as... Figure 2 As shown.
[0158] Generate the target response message based on at least one of the following: the business ID (businessId) associated with the workflow instance, the business-associated instance key (businessKey), the unique identifier (instanceId), and the start-up success indication field.
[0159] After a workflow instance starts successfully, the workflow parsing engine sends the workflow instance ID and other relevant information back to the specific business service. Specifically, once a workflow instance starts successfully, the workflow parsing engine sends the workflow instance ID and other relevant information to the specific business service, which then sends this information to the topic being listened to by the business service. In this way, interaction is established between the workflow service and the specific business service. The workflow service is responsible for starting and managing workflow instances and sending relevant information back to the business service, which can then perform subsequent processing and operations based on this information.
[0160] In this embodiment, the message queue-based communication method helps to achieve decoupling and flexibility of the system, enabling different services to be developed and deployed independently, while achieving effective collaboration and data exchange through message queues.
[0161] like Figure 4 As shown, after the above workflow instance starts successfully, the method also includes:
[0162] Step S204: Call the general approval entry defined in the workflow service to approve each node in the workflow instance and generate a notification message corresponding to the approval of the current node. The notification message includes: an indication field indicating whether the approval is passed, as well as the identifier of the current node and the unique identifier of the workflow instance.
[0163] Step S205: Add the notification message to the message queue so that the corresponding business service can listen for and obtain the notification message in the message queue.
[0164] In this embodiment, the functions or methods on the workflow server side, such as service A, also include: using Activiti as the process execution framework, creating and starting corresponding workflow instances based on at least one approval business request from at least one business server, and listening to, parsing, and recording data in the message queue, and sending response messages and / or notification messages to the message queue.
[0165] Furthermore, such as Figure 6As shown, this workflow service node (service A registered as a workflow execution service node) can include a workflow execution unit and a workflow parsing engine. The workflow execution unit uses Activiti as the process execution framework and is responsible for creating and starting workflow instances. The workflow parsing engine listens to, parses, and records Kafka data, sends data to Kafka, and also provides the ability to handle the front-end approval public access interface.
[0166] The workflow instance startup method provided in this embodiment starts on the business server and sends an approval business request to the message queue. The message queue then sends this approval business request to the workflow server, enabling the workflow server to quickly initiate the approval process. This reduces potential delays in traditional methods and improves the timeliness of business processing. Simultaneously, this method clearly defines the subject to be monitored, the business ID, and the workflow instance type, making the startup of the approval process more precise and efficient. Furthermore, by using workflow-driven mechanisms, the workflow approval process is decoupled from the associated actual business processing, ensuring that changes to one side's code do not affect the other side's code, reducing code processing time and improving the efficiency of workflow instance startup and approval.
[0167] Furthermore, when multiple business services have the same approval process, this method uses a workflow service as a unified interface for the approval process, providing a common approval interface for business services with the same approval process. This avoids adding new approval processes to each service with the same approval process, reducing the interface development process and improving development efficiency.
[0168] The following is combined Figure 5 and Figure 6 The method for starting a workflow instance provided by this invention is described below. See also... Figure 5 This is a signaling diagram of data flow between a workflow service and an actual business service provided in an embodiment of the present invention; Figure 6 Is with Figure 5 A diagram illustrating the corresponding data flow.
[0169] like Figure 6 As shown, the approval process type is named CommonAuditProcess. This approval process includes nodes such as "Application," "Project Manager Approval," "Department Manager Approval," and "General Manager Approval," where each node is a single instance (i.e., the approver or executor is the same person). (See attached...) Figure 2 Among the nodes, the "Application" node is initiated and submitted by business BB, CB, and DB to service A to start the Activiti instance. The "Project Manager Approval", "Department Manager Approval", and "General Manager Approval" nodes are initiated by the general approval interface provided by service A.
[0170] This case study uses Spring Cloud as the microservice architecture and Kafka as the message queue. Service A is the registration workflow service. The workflow execution unit uses Activiti as the process execution framework, responsible for creating and starting workflow instances. The workflow parsing engine listens for, parses, and records Kafka data, and sends data to Kafka. Additionally, it provides the ability to handle public access interfaces for front-end approvals. Services B, C, and D contain business processes that require initiating approval workflows. These businesses share the same Activiti approval model (i.e., they all use the append function). Figure 2 The approval process is as follows: each business needs to undergo additional operations after each approval node is completed.
[0171] The following description uses business BB, which uses services A and B, as an example. The basic process is as follows:
[0172] Step S1: Start the relevant business and add a workflow approval process. Use the front-end workflow startup application interface.
[0173] Step S2: Business service B sends an approval business request, informing the workflow service of the topic to be monitored, the associated business ID, the type of workflow instance to be started, etc.
[0174] Business service B initiates an approval process business request. After completing the business-related work, it calls the Kafka (message queue system) connection and sends relevant information, such as: the type of workflow instance to be created for this business, the topic to be listened to, the associated business ID, project manager, department manager, general manager, etc.
[0175] Step S3: The Kafka engine listens to the message queue. Specifically, it listens for any business services sending approval requests.
[0176] The business backend sends the processed "approval business request" data to the Kafka software; then, the receiving module in the Kafka software (such as topic-a real-time listener) determines the object to be sent (service A) and sends the processed "approval business request" data to service A.
[0177] In this context, the Kafka software determines that the object to be sent is service A based on the pre-established relationship between topic-a and a unique business function in service A. This unique relationship can be determined through step S100-1 of the aforementioned embodiment, which can be understood as: it is pre-defined that all data / messages received in real-time from topic-a are sent to service A.
[0178] In this embodiment, the approval submission initiation interface for business approval is defined in the specific service where the business resides (i.e., the front-end approval initiation interface is defined in BB, CB, and DB respectively). After the BB business completes the internal data processing of the "application" node, it calls the Kafka software connection related code to send the relevant information for creating the approval instance to the topic-a topic of the Kafka software service. This relevant information includes the content circled ① to ⑤ above.
[0179] Optionally, the Kafka software processes relevant data within the business (such as modifying special fields) to obtain related information circles ① to ⑤, with the purpose of indicating that the business approval application has been submitted. For example, a code example of such information is as follows:
[0180] {
[0181] “processType”: “CommonAuditProcess”, (the type of workflow instance to be created for this business);
[0182] “listenTopic”: “topic-b”, (The topic to be listened to when receiving feedback information in the later stages of this service);
[0183] "businessId": "1", (The business ID that the approval process instance is to be associated with);
[0184] "businessKey": "BusinessB", (The business ID will be retrieved from table B after receiving feedback information).
[0185] “projectUser”: “xxx”, (The project manager who needs approval is xxx);
[0186] “departmentUser”: “yyy”, (The department manager who needs approval is yyy);
[0187] "generalUser": "zzz", (The general manager who needs approval is zzz);
[0188] }
[0189] Meanwhile, service B starts the Kafka listening function to listen for messages returned by topic-b.
[0190] Step S4: Workflow service A obtains the data parsed by the engine and starts the workflow instance.
[0191] Step S5: After the workflow starts successfully, workflow service A informs the specific workflow instance ID, etc., through Kafka.
[0192] Specifically, the workflow parsing engine of workflow service A starts listening for topic-a messages in Kafka. When it detects the start task of the approval instance, it begins parsing the approval business request to obtain relevant information, namely the content mentioned in ① to ⑤ above. Based on the parsing results, it calls the workflow execution unit to prepare to start the workflow instance and automatically generates a unique ID (instanceId, assumed to be "10001") to identify the instance. This unique ID is a newly added ID in workflow service A, let's assume it's marked as ⑥.
[0193] The analysis results show that the workflow needs to create an instance of model ① "CommonAuditProcess". When the instance starts, the project manager node of the instance is set to "xxx", the department manager node is set to "yyy", and the general manager node is set to "zzz". After the workflow instance starts successfully, a unique ID (instanceId, assumed to be "10001"⑥) will be created for the instance.
[0194] The workflow parsing engine records related data in the database, including instanceId (10001), listenTopic (topic-b), businessId (1), and businessKey (BusinessB). Then, the workflow service A's parsing engine sends a successful startup message back to business service B. Based on the above relationships, it determines that the feedback data should be sent to the Kafka topic-b. The feedback response message is as follows:
[0195] {
[0196] "businessId": "1", (The business ID that the approval process instance is to be associated with);
[0197] "businessKey": "BusinessB", (the instance keyword associated with the BB business);
[0198] “instanceId”: “10001” (New addition, a unique ID used to identify this workflow instance);
[0199] "instanceNode": "applyNode", (Add a new node; the system executes the "apply" node request);
[0200] "code": 200 (New, indicating a success message);
[0201] }
[0202] When the Kafka software receives a message from topic-b, it directly sends the message to the business service B that is listening to that topic.
[0203] Step S6: Business service B listens to the message queue and parses information such as the workflow instance ID.
[0204] Business service B starts listening to topic-b in Kafka. After receiving a response message from workflow service A, it parses it to confirm success (code 200 indicates successful startup) and finds that its instanceNode is applyNode (indicating that the node that has completed execution is the "application" node). The system executes the relevant operations of the "application" node. Specifically, business service B finds the data table associated with the BusinessB instance through businessKey and updates the workflow instance ID (10001) to the entry with an ID value of 1 in the table.
[0205] At this point, the workflow approval instance creation process is complete. The "Application" node of business BB has been completed and the approval process has been successfully created, with the approval process now executing up to the "Project Manager Approval" node. This embodiment specifies that since BB, CB, and DB share the same approval process, interfaces for "Project Manager Approval," "Department Manager Approval," and "General Manager Approval" nodes will not be defined separately in services B, C, and D. Instead, the approval interface for each node in B, C, and D is shared (i.e., the same interface is used in services B, C, and D for project manager approval). Therefore, the processing interfaces for "Project Manager Approval," "Department Manager Approval," and "General Manager Approval" are defined in service A. There are no approval entry points in services B, C, and D. This method, compared to the general approach of defining a separate "Project Manager Approval" interface in services B, C, and D and then remotely calling service A after processing one's own business, avoids adding new approval processes to each service with the same approval process, reducing interface development time and improving development efficiency.
[0206] like Figure 5 As shown, the above method also includes:
[0207] Step S7: Workflow service A calls the general approval entry defined in workflow service (A).
[0208] Step S8: Workflow service A executes the current node and sends a notification to the associated business service (including whether the approval has been granted).
[0209] Step S9: Business service B performs relevant business processing based on the notification content.
[0210] Specifically, after the project manager associated with business BB receives the information that the business with ID "1" needs to be approved, he approves it in the system by calling the approval entry in service A. The approval message is as follows (approval data structure).
[0211] Service A's approval entry point is handled by the workflow parsing engine. After receiving the message and parsing that the project manager "agrees" to the application, the parsing engine calls the workflow execution unit to continue the execution of the instance with workflow 10001, forwarding it to the "department manager approval" node. After receiving the successful execution from the execution unit, it searches for the information associated with 10001 in the aforementioned related database, and finds the listenTopic (topic-b), businessId(1), and businessKey (BusinessB) information. Then, it sends the approval result of this node to topic-b in Kafka. The structure of the approval data included in the approval result is as follows:
[0212] {
[0213] "instanceId":"10001",
[0214] "accept": true,
[0215] "msg": "Agree",
[0216] }
[0217] Service A encapsulates the above approval data into a notification message, and then sends the notification message to Kafka. One possible data structure for a notification message sent to Kafka is as follows:
[0218] {
[0219] “businessId”:“1”
[0220] "businessKey":"BusinessB",
[0221] "instanceId":"10001",
[0222] "instanceNode":"projectUserNode",
[0223] "accept": true,
[0224] "msg": "Agree",
[0225] “code”:200,
[0226] }
[0227] The operation of executing the next node is carried out in the same way as step S7 above. According to steps S8 and S9, after service B parses the notification messages or information listened to in topic-b, it determines that the next node to be executed is projectUserNode. Then the system executes the relevant operations of the "Department Manager Approval" node.
[0228] Similarly, the operations for the "Department Manager Approval" and "General Manager Approval" nodes are the same as those for the aforementioned steps S7 to S9, and will not be repeated in this embodiment.
[0229] This embodiment provides a general interface processing method for the same approval process, and proposes a solution for sharing the same approval process across multiple business units. This method decouples the workflow approval process from the associated actual business processing through workflow-driven approaches, ensuring that changes to code in one party will not affect code in another, thus reducing code processing time. Furthermore, by unifying the approval interfaces for the same nodes into a single interface, it also reduces interface development and improves development efficiency.
[0230] It should be noted that the above-mentioned synchronization process in this embodiment includes a rollback method when an anomaly occurs between the workflow service and the associated service.
[0231] This embodiment also provides a workflow instance initiation device for implementing the above embodiments and preferred embodiments, and details already described will not be repeated. As used below, the term "module" can be a combination of software and / or hardware that implements a predetermined function. Although the device described in the following embodiments is preferably implemented in software, hardware implementation, or a combination of software and hardware, is also possible and contemplated.
[0232] This embodiment provides a workflow instance startup device, applicable to any business server, or used to implement the functions of the aforementioned business server, such as... Figure 7 As shown, the starting device includes: a first sending module 710, a first listening module 720, a parsing module 730, and a determining module 740. In addition, the device may include other more or fewer modules, which is not limited in this embodiment.
[0233] The first sending module 710 sends an approval business request to the message queue. The approval business request is used to start the approval process and to inform the service of at least one of the following: the topic to be listened to, the associated business ID, and the type of workflow instance to be started. The approval process is at least the same as the approval process of the second business service.
[0234] The first listening module 720 is used to listen in real time to the response messages fed back by the workflow service in the message queue according to the preset association relationship, wherein the preset association relationship includes the correspondence between each type of business and a topic.
[0235] The parsing module 730 is used to parse the target response message when the target response message corresponding to the approval business request is detected. The target response message is generated based at least on the topic, the business ID and the workflow instance type.
[0236] The determination module 740 is used to determine, based on the content of the target response message, that the workflow instance corresponding to the approval business request has been successfully started, and to execute the approval operations of each node in the workflow instance.
[0237] In addition, this embodiment also provides another workflow instance startup device, which is applied to the workflow server or used to implement the functions of the aforementioned workflow server, such as... Figure 8 As shown, the device includes a second listening module 810, a processing module 820, and a second transmitting module 830. In addition, the device may include other modules, such as a storage module and a receiving module, etc. This embodiment does not limit this.
[0238] The second listening module 810 is used to listen to the approval business request sent by the first business service through the message queue. The approval business request includes at least one of the following: the topic to be listened to by the first business service, the associated business ID, and the type of workflow instance to be started. The approval process is at least the same as the approval process of the second business service.
[0239] The processing module 820 is used to parse the approval business request, create a workflow instance based on the content of the approval business request, and generate a target response message indicating that the workflow instance has started successfully.
[0240] The second sending module 830 is used to send the target response message to a message queue according to a preset association relationship, so that the first service can listen to and obtain the target response message in the message queue. The preset association relationship includes the correspondence between the first service and the topic to be listened to.
[0241] Further functional descriptions of the above modules and units are the same as those in the corresponding embodiments described above, and will not be repeated here.
[0242] In this embodiment, the workflow instance's startup device is presented in the form of a functional unit. Here, a unit refers to an ASIC (Application Specific Integrated Circuit) circuit, a processor and memory that execute one or more software or fixed programs, and / or other devices that can provide the above-mentioned functions.
[0243] This invention also provides an electronic device having the above-described features. Figure 7 or Figure 8 The startup device for the workflow instance shown.
[0244] Please see Figure 9 This is a schematic diagram of an electronic device provided in an optional embodiment of the present invention. The electronic device includes one or more processors 10, a memory 20, and interfaces for connecting the various components, including high-speed interfaces and low-speed interfaces. The various components communicate with each other using different buses and can be installed on a common motherboard or otherwise as needed. The processor can process instructions executed within the electronic device, including instructions stored in or on the memory to display graphical information of a GUI on an external input / output device (such as a display device coupled to the interface).
[0245] In some alternative implementations, multiple processors and / or multiple buses can be used with multiple memories and multiple memory units, if desired. Similarly, multiple computer devices can be connected, each providing some of the necessary operations (e.g., as a server array, a group of blade servers, or a multiprocessor system). Figure 9 Take a processor 10 as an example.
[0246] Processor 10 may be a central processing unit, a network processor, or a combination thereof. Processor 10 may further include a hardware chip. The hardware chip may be an application-specific integrated circuit (ASIC), a programmable logic device (PLD), or a combination thereof. The programmable logic device may be a complex programmable logic device (CAMP), a field-programmable gate array (FPGA), a general-purpose array logic (GDA), or any combination thereof.
[0247] The memory 20 stores instructions executable by at least one processor 10 to cause the at least one processor 10 to execute a startup method for implementing the workflow instance shown in the above embodiments.
[0248] The memory 20 may include a program storage area and a data storage area. The program storage area may store the operating system and applications required for at least one function; the data storage area may store data created based on the use of the electronic device. Furthermore, the memory 20 may include high-speed random access memory and may also include non-transitory memory, such as at least one disk storage device, flash memory device, or other non-transitory solid-state storage device. In some alternative embodiments, the memory 20 may include memory remotely located relative to the processor 10, and these remote memories may be connected to the electronic device via a network. Examples of such networks include, but are not limited to, the Internet, intranets, local area networks, mobile communication networks, and combinations thereof.
[0249] The memory 20 may include volatile memory, such as random access memory; the memory may also include non-volatile memory, such as flash memory, hard disk or solid-state drive; the memory 20 may also include a combination of the above types of memory.
[0250] The computer device also includes input and output devices. The processor 10, memory 20, input devices, and output devices can be connected via a bus or other means. Figure 9 Taking the bus connection between China and Israel as an example.
[0251] The input device can receive input numerical or character information, and generate key signal inputs related to user settings and function control of the computer device, such as a touchscreen, keypad, mouse, trackpad, touchpad, joystick, one or more mouse buttons, trackball, joystick, etc. The output device may include a display device, auxiliary lighting devices (e.g., LEDs), and haptic feedback devices (e.g., vibration motors). The aforementioned display devices include, but are not limited to, liquid crystal displays, light-emitting diodes, displays, and plasma displays. In some optional embodiments, the display device may be a touchscreen.
[0252] The electronic device also includes at least one communication interface 30 for communicating with other devices or communication networks.
[0253] Optionally, the aforementioned electronic device may be a server or server cluster, or it may be other network devices.
[0254] This invention also provides a service system, the system structure of which is as follows: Figure 6 As shown, it includes: at least one business server, a workflow server, and a message queue, wherein the workflow server provides a common approval interface for at least one business server.
[0255] The message queue is used to send and receive request, data, or notification messages between each business server and the workflow server. Furthermore, the message queue is the Kafka software system.
[0256] Any of the business servers can be used to execute the aforementioned... Figure 1 , Figure 3 and Figure 5 The workflow instance shown is started using this method. The workflow server can be used to execute the aforementioned... Figure 4 and Figure 5 The startup method for the workflow instance shown.
[0257] The service system provided in this embodiment starts on the business server side and sends an approval business request to the message queue. The message queue then forwards this approval business request to the workflow server side, enabling the workflow server to quickly initiate the approval process. This reduces potential delays in traditional methods and improves the timeliness of business processing. Simultaneously, this method clearly defines the subject to be monitored, the business ID, and the workflow instance type, making the initiation of the approval process more precise and efficient. Furthermore, by using workflow-driven mechanisms, the workflow approval process is decoupled from the associated actual business processing, ensuring that changes to one side's code do not affect the other, reducing code processing time and improving the efficiency of workflow instance startup and approval.
[0258] Furthermore, when multiple business services have the same approval process, this method uses a workflow service as a unified interface for the approval process, providing a common approval interface for business services with the same approval process. This avoids adding new approval processes to each service with the same approval process, reducing the interface development process and improving development efficiency.
[0259] This invention also provides a computer-readable storage medium in which the methods described in this invention can be implemented in hardware or firmware, or implemented as recordable on a storage medium, or implemented as computer code originally stored on a remote storage medium or a non-transitory machine-readable storage medium and to be stored on a local storage medium after being downloaded via a network, so that the methods described herein can be stored on such software processing on a storage medium using a general-purpose computer, a dedicated processor, or programmable or dedicated hardware.
[0260] The storage medium can be a magnetic disk, optical disk, read-only memory, random access memory, flash memory, hard disk, or solid-state drive, etc.; furthermore, the storage medium can also include combinations of the above types of memory. It is understood that a computer, processor, microprocessor controller, or programmable hardware includes storage components capable of storing or receiving software or computer code, which, when accessed and executed by the computer, processor, or hardware, implements the methods shown in the above embodiments.
[0261] Embodiments of this application may also provide a computer program product, including computer program instructions, which, when executed by a processor, cause the processor to perform the steps in the methods described above. The computer program product may be written in any combination of one or more programming languages to perform the operations of the embodiments of this disclosure. The programming languages include object-oriented programming languages such as Java and C++, as well as conventional procedural programming languages such as C or similar languages. The program code may execute entirely on a user's computing device, partially on a user's device, as a standalone software package, partially on a user's computing device and partially on a remote computing device, or entirely on a remote computing device or server.
[0262] The above embodiments are only used to illustrate the technical solutions of the embodiments of the present invention, and are not intended to limit them. Although the embodiments of the present invention have been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A method of starting a workflow instance, characterized by, Applied to the first business server, the method includes: Establishing a preset association includes: establishing an association between a workflow service and a shared topic in a message queue, and establishing at least one association between at least one business service, each of which is a one-to-one correspondence between a business service and a listening topic in a message queue, wherein the at least one business service includes the first business service; Initiate and send an approval business request to the message queue. The approval business request is used to start the approval process and inform the service of at least one of the following: the topic to be listened to, the associated business ID, and the type of the workflow instance to be started. The approval process is at least the same as the approval process of the second business service. According to the preset association, the response messages fed back by the workflow service are monitored in real time in the message queue, wherein the preset association includes the correspondence between each type of business and a topic; When the target response message corresponding to the approval business request is detected, the target response message is parsed. The target response message is generated based on at least the topic, the business ID, and the workflow instance type. Based on the content of the target response message, it is determined that the workflow instance corresponding to the approval business request has been successfully started, and the approval operations of each node in the workflow instance are executed according to the workflow instance; The message queue also includes a notification message corresponding to the approval of the current node. The notification message is used to enable the corresponding business service to listen for and obtain the notification message in the message queue. The notification message is generated by the workflow server after the workflow instance starts successfully by calling the general approval entry defined in the workflow service to approve each node in the workflow instance. The notification message includes: an indication field indicating whether the approval is passed, as well as the identifier of the current node and the unique identifier of the workflow instance.
2. The method according to claim 1, characterized in that, Before initiating and sending the approval request to the message queue, the following steps are also included: The parsing of the target response message includes: Parse the target response message to obtain at least one of the following: the business ID to be associated with the workflow instance of the approval process, the business-associated instance keyword, the unique identifier of the workflow instance, and the start-up success indication field; The step of determining that the workflow instance corresponding to the approval business request has started successfully based on the content of the target response message includes: If the content obtained after parsing the target response message contains the indication field indicating successful startup, then the corresponding workflow instance is determined to have started successfully.
3. The method according to claim 2, characterized in that, Each node in the workflow instance includes an application node, and the method further includes: When the content obtained by parsing the target response message indicates that the application node in the workflow instance has been completed, the data table associated with the current instance is searched according to the instance keyword associated with the business. Update the unique identifier of the workflow instance to the entry in the data table whose ID value is the first value.
4. The method according to any one of claims 1-3, characterized in that, The step of executing the approval operations at each node of the workflow instance includes: The message queue receives a notification message after the workflow service has approved the current node. The notification message includes: an indication field indicating whether the approval has passed, as well as the identifier of the current node and the unique identifier of the workflow instance. According to the notification message, if the indication field indicates approval, the workflow operation of the current node is executed based on the identifier of the current node.
5. A method for starting a workflow instance, characterized in that, Applied to a workflow server, the workflow server has the functions of workflow execution and providing a common approval interface for at least one business server. The method includes: Listen for approval business requests sent by the first business service through a message queue. The approval business request includes at least one of the following: the topic to be listened to by the first business service, the associated business ID, and the type of workflow instance to be started, and the approval process is at least the same as the approval process of the second business service. Parse the approval request, create a workflow instance based on the content of the approval request, and generate a target response message indicating that the workflow instance has started successfully; The target response message is sent to a message queue according to a preset association relationship, so that the first business service can listen to and obtain the target response message in the message queue. The preset association relationship includes: the correspondence between the first business service and the topic to be listened to; the preset association relationship is established by the first business service, and the establishment of the preset association relationship by the first business service includes: establishing an association relationship between a workflow service and a shared topic in the message queue, and establishing at least one association relationship for at least one business service, each of the association relationships being: a one-to-one correspondence between a business service and a listening topic in the message queue, and the at least one business service including the first business service; After the workflow instance starts successfully, the process further includes: calling the general approval entry defined in the workflow service to approve each node in the workflow instance and generating a notification message corresponding to the approval of the current node. The notification message includes: an indication field indicating whether the approval is passed, as well as the identifier of the current node and the unique identifier of the workflow instance; and adding the notification message to the message queue so that the corresponding business service can listen for and obtain the notification message in the message queue.
6. The method according to claim 5, characterized in that, The step of creating a workflow instance based on the content of the approval business request and generating a target response message indicating that the workflow instance has started successfully includes: Based on the content of the approval request, prepare to start the workflow instance; Once the workflow instance starts successfully, a unique identifier for the workflow instance and a success indication field are generated. The target response message is generated based on at least one of the following: the business ID to be associated with the workflow instance, the instance keyword associated with the business, the unique identifier, and the start-up success indication field.
7. The method according to any one of claims 5-6, characterized in that, The method further includes: Using Activiti as the process execution framework, a corresponding workflow instance is created and started based on at least one approval business request from at least one business server, and... The system monitors, parses, and records the data in the message queue, and sends response messages and / or notification messages to the message queue.
8. A workflow instance initiation device, characterized in that, The device, applicable to any business server, includes: The device is used to establish preset associations, including: establishing an association between a workflow service and a shared topic in a message queue, and establishing at least one association between at least one business service, each association being a one-to-one correspondence between a business service and a listening topic in the message queue, wherein the at least one business service includes a first business service; the message queue also includes a notification message corresponding to the approval of the current node, wherein the notification message is used to enable the corresponding business service to listen to and obtain the notification message in the message queue; the notification message is generated by the workflow server after the workflow instance is successfully started, by calling the general approval entry defined in the workflow service to approve each node in the workflow instance, and the notification message includes: an indication field indicating whether the approval is passed, as well as the identifier of the current node and the unique identifier of the workflow instance; The first sending module is used to send an approval business request to the message queue. The approval business request is used to start the approval process and to inform the service of at least one of the following: the topic to be listened to, the associated business ID, and the type of workflow instance to be started. The approval process is at least the same as the approval process of the second business service. The first listening module is used to listen to the response messages fed back by the workflow service in real time in the message queue according to the preset association relationship, wherein the preset association relationship includes the correspondence between each type of business and a topic; The parsing module is used to parse the target response message when the target response message corresponding to the approval business request is detected. The target response message is generated based at least on the topic, the business ID and the workflow instance type. The determination module is used to determine, based on the content of the target response message, that the workflow instance corresponding to the approval business request has been successfully started, and to execute the approval operations of each node in the workflow instance.
9. A workflow instance initiation device, characterized in that, The device, applied to a workflow server, includes: The second listening module is used to listen for approval business requests sent by the first business service through the message queue. The approval business request includes at least one of the following: the topic to be listened to by the first business service, the associated business ID, and the type of workflow instance to be started, and the approval process is at least the same as the approval process of the second business service. The processing module is used to parse the approval business request, create a workflow instance based on the content of the approval business request, and generate a target response message indicating that the workflow instance has started successfully. The second sending module is used to send the target response message to a message queue according to a preset association relationship, so that the first business service can listen to and obtain the target response message in the message queue. The preset association relationship includes: the correspondence between the first business service and the topic to be listened to; the preset association relationship is established by the first business service, and the establishment of the preset association relationship by the first business service includes: establishing an association relationship between a workflow service and a shared topic in the message queue, and establishing at least one association relationship for at least one business service, each of the association relationships being: a one-to-one correspondence between a business service and a listening topic in the message queue, and the at least one business service including the first business service; After the workflow instance is successfully started, the device is further configured to: call the general approval entry defined in the workflow service, approve each node in the workflow instance, and generate a notification message corresponding to the approval of the current node. The notification message includes: an indication field indicating whether the approval is passed, as well as the identifier of the current node and the unique identifier of the workflow instance; add the notification message to the message queue so that the corresponding business service listens for and obtains the notification message in the message queue.
10. An electronic device, characterized in that, It includes a memory and a processor, wherein the memory and the processor are connected. The memory stores computer instructions, and the processor executes the computer instructions to perform the startup method of a workflow instance according to any one of claims 1 to 4, or any one of claims 5 to 7.
11. A service system, characterized in that, The system includes: at least one business server, a workflow server, and a message queue, wherein the workflow server provides a public approval interface for the at least one business server; The message queue is used to send and receive request, data, or notification messages between each business server and the workflow server; The business server is used to execute the startup method of the workflow instance as described in any one of claims 1 to 4; The workflow server is used to execute the startup method of the workflow instance as described in any one of claims 5 to 7.
12. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer instructions for causing the computer to perform a method for starting a workflow instance as described in any one of claims 1 to 4, or any one of claims 5 to 7.
Citation Information
Patent Citations
Cross-service system process monitoring device and method, corresponding equipment and storage medium
CN112200505A
Business data approval method and device
CN116433167A