이 콘텐츠는 선택한 언어로 제공되지 않습니다.
Chapter 27. BPMN process fluent API for Business Central processes
Red Hat Process Automation Manager provides a BPMN process fluent API that enables you to create business processes using factories. You can also manually validate the business process that you created using process fluent API. The process fluent API is defined in the org.kie.api.fluent package.
Therefore, instead of using BPMN2 XML standard, you can use the process fluent API to create business processes in a few lines of code.
27.1. Example requests with the BPMN process fluent API 링크 복사링크가 클립보드에 복사되었습니다!
The following example includes BPMN process fluent API requests for basic interactions with a business process. For more examples, download the Red Hat Process Automation Manager 7.9.1 Source Distribution from the Red Hat Customer Portal and navigate to ~/rhpam-7.9.1-sources/src/droolsjbpm-knowledge-$VERSION/kie-api/src/main/java/org/kie/api/fluent.
- Creating and interacting with Business Central business processes
The following example shows basic business process with a script task, an exception handler, and a variable:
Example request to create and interact with a Business Central business process
Copy to Clipboard Copied! Toggle word wrap Toggle overflow In this example, a
ProcessBuilderFactoryreference is obtained and then, usingprocessBuilder(String processId)method, aProcessBuilderinstance is created, which is associated with the given process Id. TheProcessBuilderinstance enables you to build a definition of the created process using the fluent API.A business process consists of three components:
Header: The header section contains global elements such as the name of the process, imports, and variables.
In the previous example, the header contains the name and version of the process and the package name.
Nodes: The nodes section contains all the different nodes that are part of the process.
In the previous example, nodes are added to the process by calling the
startNode(),actionNode(), andendNode()methods. These methods return a specificNodeBuilderthat allows you to set the properties of that node. After the code finishes configuring that specific node, thedone()method returns theNodeContainerBuilderto add more nodes, if necessary.Connections: The connections section links the nodes to create a flow chart.
In the previous example, once you add all the nodes, you must connect them by creating connections between them. You can call the
connection()method, which links the nodes.
Finally, you can call the
build()method and obtain the generated process definition. Thebuild()method also validates the process definition and throws an exception if the process definition is not valid.
27.2. Example requests to execute a business process 링크 복사링크가 클립보드에 복사되었습니다!
Once you create a valid process definition instance, you can execute it using a combination of public and internal KIE APIs. To execute a process, create a Resource, which is used to create a KieBase. Using the KieBase, you can create a KieSession to execute the process.
The following example uses ProcessBuilderFactory.toBytes process to create a ByteArrayResource resource.
Example request to execute a process