Barbados Crisis Management System
-BCMS-

Camunda

Barbados Crisis Management System
-BCMS-

Camunda


Download BCMS_C8.ts.zip file ⤳ case study is based on Node.js and written in TypeScript

Requirements
pages #7 and #8

Camunda Modeler process application*

│   .bcms # Node.js environment var. including the location of Camunda 8 Run
│   .process-application # Camunda Modeler config. file to deploy all BPMN/DMN files in one shot
│   package.json # Node.js config. file
│   README.md
│   tsconfig.json # TypeScript compiler options
│
├───resources
│       BCMS_Req._1_C8.bpmn # BPMN collaboration diagram with 3 communicating pools/processes
│       BCMS_Req._2_C8.bpmn # Unused for the moment
│
└───ts # TypeScript code as client app. of Camunda 8 Run
        BCMS_Req_1.ts # *AUTOMATICALLY* deploys, instantiates and runs "BCMS_Req._1_C8.bpmn"

*Do not deploy BCMS_Req._1_C8.bpmn file from Camunda Modeler (error will appear) since deployment occurs when executing BCMS_Req_1.ts file

Req. 1

Fire Station Coordinator -FSC- is a business process that is opened each time a crisis occurs. This is the same for Police Station Coordinator -PSC-

Req. 1 is the modeling of the opening and the closing (intermediate activities are left abstract for the sake of simplification) of a (master) crisis management business process

Collaboration is handled by means BPMN (throw/catch) message events and BPMN (throw/catch) signal events. Both BPMN communication event types are used for illustration only. This especially allows the understanding of the difference in the Node.js code between messages and signals

Test Req. 1 on LiveBPMN.com
Crisis management -start & end- icon (top-right menu)

BPMN ⤳ diagram

Deployment and instantiation ⤳ Node.js code

class Crisis_management {
    static {
        BCMS_Req_1.Client.deployResourcesFromFiles([path.join(process.cwd(), "resources/BCMS_Req._1_C8.bpmn"),]).then(response => { // console.log(JSON.stringify(response));
            for (const deployment of response.deployments) {
                console.info(`Deployment "${deployment.processDefinition!.processDefinitionId}"`);
                if (deployment.processDefinition!.processDefinitionId === process.env.ID_Crisis_management) {
                    const crisis_management = BCMS_Req_1.Client.createProcessInstance({
                        processDefinitionId: process.env.ID_Crisis_management as ProcessDefinitionId,
                        // processDefinitionVersion: 1, // By default, last version is used...
                        variables: {crisis_id_: Crisis_id_}
                        // awaitCompletion: true
                    });
                    crisis_management.then(instance => console.info(`\n"${instance.processDefinitionId}" instantiated\n`));
                }
            }
        }).catch(error => console.error(`"${error.path}" not found`));
    }
    …
}

Message throw ⤳ diagram

Message catch

Message throw job worker ⤳ Node.js code

class Crisis_management {
    static { /* Deployment and instantiation of 'Crisis management' (master) business process */ }
    private static _FSC_aware = BCMS_Req_1.REST_client.createJobWorker<Crisis, any>({
        type: 'FSC_aware', // 'type' field in model...
        timeout: 10000, // Timeout for the job worker to complete the job before it is available for another worker poll...
        maxJobsToActivate: 5, // Maximum number of jobs to process concurrently...
        worker: 'FSC_aware worker',
        jobHandler: (job, log) => {
            if (job.variables.crisis_id_) {
                console.info(`\t${Crisis_management.name} throws message ${job.type} '${job.variables.crisis_id_}'`);
                BCMS_Req_1.Client.correlateMessage({ // FSC business process is started with 'crisis_id_' as initial data...
                    name: "Make_FSC_aware",
                    variables: {crisis_id_: job.variables.crisis_id_}
                });
                return job.complete();
            }
            console.error(job.type + " throws message -> failure");
            // Replace "message throw event" in the BPMN by "task throw event" with "error boundary event":
            return job.error({variables: {}, errorCode: "FSC_aware_failure"});
        }
    });
}

Signal throw

Contrary to messages, signals do not require correlation and thus specific Node.js code

Signal catch

Contrary to messages, signals do not require correlation and thus specific Node.js code

Ad hoc subprocess

Activities within ad hoc subprocess is statically defined below while an array var. may (dynamically) state which activities have to be launched

Execution ⤳ log

> tsx --env-file=.bcms ./ts/BCMS_Req_1.ts my_crisis_id_
Deployment "ID_BCMS_req_1_FSC"
Deployment "ID_BCMS_req_1_PSC"
Deployment "ID_Crisis_management"
"ID_Crisis_management" instantiated
        Crisis_management throws message PSC_aware 'my_crisis_id_'
        Crisis_management throws message FSC_aware 'my_crisis_id_'
        PSC catches message Make_PSC_aware 'my_crisis_id_'
        FSC catches message Make_FSC_aware 'my_crisis_id_'
        PSC throws signal PSC_connected
        Crisis_management catches signal PSC_connected_
        FSC throws signal FSC_connected
        Crisis_management catches signal FSC_connected_
        PSC Policemen_work_on_crisis
        FSC Firemen_work_on_crisis
        PSC throws signal PSC_agrees_to_close_crisis
        FSC throws signal FSC_agrees_to_close_crisis

BPMN ⤳ execution

© BarbierDarnal.com