Triggering the BPM process from the Ws-appserver

Source: Internet
Author: User

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.

    1. Create the business process model and publish it to the tenant;
    2. 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);
    3. 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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.