Before you begin
Before using the BPM process model, you need to publish the process model to the runtime.
Ws-appserver app contains the business logic necessary to execute the activity. Usually, these In-app logic Execute as part of the business process cycle.
on the other hand, at run time, the process model can also be triggered by the Ws-appserver application. The following procedure describes the process.
- Create the business process model and publish it to the tenant;
- In the Java class Extension class, add the code that triggers the Orchestration model (the code snippet that will be seen in the following example);
- Generate Java code again and the Web Service Interface (Web service Interface) and publish it to the tenant.
The application configures the necessary logic to trigger the business process model.
Example
For example, there is a sales application that involves national, regional, and local data. In the application, logic code is embedded to trigger the business process notification message each time a new zone is added. The program will send an email to all stakeholders.
The following describes how this logic is integrated into the application code.
Attention
Suppose that there is already a class called "region" in the application.
The system also has a published business process model, named "SENDMAIL_VCMDEMO10.BPM", which will send an e-mail message to the specified user.
In the region extension class, expand the following code:
Public class RegionextendsRegionbase{ PublicRegion () { This((Busobjectconfig)NULL); }
PublicRegion (Busobjectconfig config) { Super(config); }
@Override Public voidOnaftercommit (Aftercommitobjectevent event) { Super. Onaftercommit (event); intMessagexml = 0; try { Messagexml = Bsf.getxmldocument (). ParseString ( "<InputMessage>" + "<RegionID>" +getregionid () + "</RegionID>" + "<RegionDescription>" +getregiondescription () + "</RegionDescription>" + "</InputMessage>"); } catch(unsupportedencodingexceptionE) { throw new Bsfruntimeexception (e); } catch(XMLException e) { throw new Bsfruntimeexception (e); } //if inserting a region, then notify all employees through a flow if(Event.triggeredby (Stdtriggers.insert_object)) { intresult = wsutil.executeprocess| Wsutil.executeprocess ( Processtype.definition, "3.Business Process models/test/sendmail_vcmdemo10.bpm", "Northwind Application", NULL, NULL, NULL, Messagexml, true, True); SYSTEM.OUT.PRINTLN ("result =" +node.writetostring (result,true)); //no need to delete Messagexml node This is taken care by wsutil.executeprocess () implementation } } }
|
At run time, this code will ensure that when a zone object is committed to the database, the program sends a message to the recipient in a pre-defined message content .
In this way, the business process model is triggered by ws-appserver.
Translator's Thinking
In some transaction management, the asynchronous problem can be referred to the design: if in the process of the next operation, add trigger on WebService, start the background automatic execution process, will do the business, transaction-related work. For example, document operations on a process (saving data into MongoDB) can be designed with reference to this pattern.
Translator level is limited, welcome feedback discussion.
Triggering the BPM process from the Ws-appserver