Giter Club home page Giter Club logo

bpmn-engine's People

Contributors

allain avatar bestmazzo avatar blackgad avatar ceefour avatar j2l4e avatar leon19 avatar mdwheele avatar paed01 avatar saeedtabrizi avatar scm-sm avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

bpmn-engine's Issues

Cant catch activity error

Hi !...

Nice module! Thanks for sharing.

Need help in a thrown error:

bpmn-engine/lib/activities/Activity.js:74
    throw new Error(`Already left <${this.id}>`);

The error is valid but I cant catch it onengine.on('error') or task listener listener.on('error') .
Is there another way? Theres a mention in the docs about a bpmn:errorEvent.

Thnx!

Exception handling

Hello!

There is one more issue:
exception.zip

What expects: that I catch exception and send it message to user.
What happens:

/node_modules/bpmn-engine/lib/mapper.js:9
    throw new Error(`Unknown activity type ${type}`);
    ^

Error: Unknown activity type bpmn:SignalEventDefinition

and it exception kills whole server process.

Wrapping any part of my code by try {...} catch(e) {...} has no result, because exception produced somewhere in async code of bpmn-engine lib.

Question about Services Tasks

Hi,

I'm trying to use Bpmn-engine to execute tasks like transcoding video file, uploading file to ftp, etc...
Except that I don't want to put my entire code In a Bpmn/scriptTask. I preferred to just passed some variables in my Bpmn file and then execute them "server side". (not sure if it's really clear...). As I understand it, Bpmn/serviceTask is more suitable for my use.

An example will be more explicit :

var Bpmn = require('bpmn-engine');
    var processXml =`
<?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <process id="theProcess" isExecutable="true">
  <startEvent id="theStart" />
  <serviceTask id="serviceTask_123123" name="Transcode" camunda:expression="\${services.transcode()}" camunda:resultVariable="output" />
  <serviceTask id="serviceTask_456456" name="Move" camunda:expression="\${services.move()}" camunda:resultVariable="output" />
  <endEvent id="theEnd" />
  <sequenceFlow id="flow1" sourceRef="theStart" targetRef="serviceTask_123123" />
  <sequenceFlow id="flow2" sourceRef="serviceTask_123123" targetRef="serviceTask_456456" />
  <sequenceFlow id="flow3" sourceRef="serviceTask_456456" targetRef="theEnd" />
  </process>
</definitions>
`;

    var services = {
      transcode: function(message, callback) {
        console.log("doing transcode");
      },
      move: function(message, callback) {
        console.log("doing move");
      }
    };


    var engine = new Bpmn.Engine({
      source: processXml
    });

    engine.execute({
      services: {
        transcode: {
          type: 'global'
        },
        move: {
          type: 'global'
        }
      }
    }, function(err, execution) {
      if (err) throw err;
      execution.once('end', function() {
        console.log('End !');
      });
    });

Am I totally wrong ?

A little help would be appreciated, especially since I think I am mistaken about the use of BPMN/Script/Service.

Thanks !

HowTo: BPMN with COntext

How do we factor in COntext with BPMN, by process flow has series of steps
1 Start
1.1 Call Rest API 1
1.2 Call Rest APIs with specific params from API 1-
1.3 Decision
1.3.1 If Yes
1.3.1.1 Send something Back
1.3.1.1.1 User sends options via API
1.3.1.1.1.1 Exec Rest API 3 with user input

	1.3.2 If No
		1.3.2.1 Rest API4 with user input

2 End

  • In case of this scenario, how do i model my flow
  • Before end , my flow will return an output, which should be an input to the next step.
  • how do i keep the flow active.
  • Do i add a ctx saying if flow.step id==1.3.1.1 go to that specific step
  • before start and end?
  • And store the flow.step.id in a database outside the bpmn flow?
    Any inputs are much appreciated.
    I am using the engine purely as contextual workflow

how to get the output variables from subprocess?

sorry for boring you again~~
plz see the following bpmn, the subprocess is to determine the name, first a user task propose a draft, then the second user task confirm the final name, thus the subprocess is terminated.

Notice I defined two dataObject, m_name in subprocess and m_finalName in Main Process, the second task outputs m_finalName.
My question is how to get the finalName at the main process?

<bpmn:process id="Process_1" isExecutable="true">
<bpmn:startEvent id="StartEvent_1">
  <bpmn:outgoing>SequenceFlow_1blokv8</bpmn:outgoing>
</bpmn:startEvent>
<bpmn:sequenceFlow id="SequenceFlow_1blokv8" sourceRef="StartEvent_1" targetRef="sp1" />
<bpmn:subProcess id="sp1" name="subprocess">
  <bpmn:incoming>SequenceFlow_1blokv8</bpmn:incoming>
  <bpmn:outgoing>SequenceFlow_1aosxye</bpmn:outgoing>
  <bpmn:startEvent id="StartEvent_1jffh2p">
    <bpmn:outgoing>SequenceFlow_06ldstg</bpmn:outgoing>
  </bpmn:startEvent>
  <bpmn:sequenceFlow id="SequenceFlow_06ldstg" sourceRef="StartEvent_1jffh2p" targetRef="Task1" />
  <bpmn:userTask id="Task1" name="propose draft">
    <bpmn:extensionElements>
      <camunda:formData>
        <camunda:formField id="name" type="string" />
      </camunda:formData>
      <camunda:inputOutput>
        <camunda:outputParameter name="m_name">
          <camunda:script scriptFormat="javascript">this.name</camunda:script>
        </camunda:outputParameter>
      </camunda:inputOutput>
    </bpmn:extensionElements>
    <bpmn:incoming>SequenceFlow_06ldstg</bpmn:incoming>
    <bpmn:outgoing>SequenceFlow_14l40b3</bpmn:outgoing>
  </bpmn:userTask>
  <bpmn:dataObjectReference id="m_name" name="m_name" dataObjectRef="DataObject_16w11qa" />
  <bpmn:dataObject id="DataObject_16w11qa" />
  <bpmn:sequenceFlow id="SequenceFlow_14l40b3" sourceRef="Task1" targetRef="Task2" />
  <bpmn:endEvent id="EndEvent_0uhk3vh">
    <bpmn:incoming>SequenceFlow_039clkq</bpmn:incoming>
  </bpmn:endEvent>
  <bpmn:sequenceFlow id="SequenceFlow_039clkq" sourceRef="Task2" targetRef="EndEvent_0uhk3vh" />
  <bpmn:userTask id="Task2" name="confirm final name">
    <bpmn:extensionElements>
      <camunda:formData>
        <camunda:formField id="finalName" type="string" />
      </camunda:formData>
      <camunda:inputOutput>
        <camunda:outputParameter name="m_finalName">
          <camunda:script scriptFormat="javascript">this.finalName</camunda:script>
        </camunda:outputParameter>
      </camunda:inputOutput>
    </bpmn:extensionElements>
    <bpmn:incoming>SequenceFlow_14l40b3</bpmn:incoming>
    <bpmn:outgoing>SequenceFlow_039clkq</bpmn:outgoing>
  </bpmn:userTask>
</bpmn:subProcess>
<bpmn:endEvent id="EndEvent_0hyjotx">
  <bpmn:incoming>SequenceFlow_1aosxye</bpmn:incoming>
</bpmn:endEvent>
<bpmn:sequenceFlow id="SequenceFlow_1aosxye" sourceRef="sp1" targetRef="EndEvent_0hyjotx" />
<bpmn:dataObjectReference id="m_finalName" name="m_finalName" dataObjectRef="DataObject_1mgp2j0" />
<bpmn:dataObject id="DataObject_1mgp2j0" />
  </bpmn:process>

moddleOptions broken extension properties

the moddle options broken extensions.

I have the following sample

<?xml version="1.0" encoding="UTF-8"?>
<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="Definitions_1" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="1.6.0">
  <bpmn:process id="Process_1" isExecutable="false">
    <bpmn:startEvent id="StartEvent_1">
      <bpmn:outgoing>SequenceFlow_01du6ul</bpmn:outgoing>
    </bpmn:startEvent>
    <bpmn:sequenceFlow id="SequenceFlow_01du6ul" sourceRef="StartEvent_1" targetRef="Task_0kxsx8j" />
    <bpmn:endEvent id="EndEvent_01iocxa">
      <bpmn:incoming>SequenceFlow_02rootz</bpmn:incoming>
    </bpmn:endEvent>
    <bpmn:sequenceFlow id="SequenceFlow_02rootz" sourceRef="Task_0kxsx8j" targetRef="EndEvent_01iocxa" />
    <bpmn:serviceTask id="Task_0kxsx8j">
      <bpmn:extensionElements>
        <camunda:properties>
          <camunda:property name="service" value="myCustomService" />
        </camunda:properties>
      </bpmn:extensionElements>
      <bpmn:incoming>SequenceFlow_01du6ul</bpmn:incoming>
      <bpmn:outgoing>SequenceFlow_02rootz</bpmn:outgoing>
    </bpmn:serviceTask>
  </bpmn:process>
  <bpmndi:BPMNDiagram id="BPMNDiagram_1">
    <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Process_1">
      <bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="StartEvent_1">
        <dc:Bounds x="173" y="102" width="36" height="36" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNEdge id="SequenceFlow_01du6ul_di" bpmnElement="SequenceFlow_01du6ul">
        <di:waypoint xsi:type="dc:Point" x="209" y="120" />
        <di:waypoint xsi:type="dc:Point" x="338" y="120" />
        <bpmndi:BPMNLabel>
          <dc:Bounds x="274" y="105" width="0" height="0" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNShape id="EndEvent_01iocxa_di" bpmnElement="EndEvent_01iocxa">
        <dc:Bounds x="553" y="102" width="36" height="36" />
        <bpmndi:BPMNLabel>
          <dc:Bounds x="571" y="138" width="0" height="0" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNEdge id="SequenceFlow_02rootz_di" bpmnElement="SequenceFlow_02rootz">
        <di:waypoint xsi:type="dc:Point" x="438" y="120" />
        <di:waypoint xsi:type="dc:Point" x="553" y="120" />
        <bpmndi:BPMNLabel>
          <dc:Bounds x="496" y="105" width="0" height="0" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNShape id="ServiceTask_1xhle34_di" bpmnElement="Task_0kxsx8j">
        <dc:Bounds x="338" y="80" width="100" height="80" />
      </bpmndi:BPMNShape>
    </bpmndi:BPMNPlane>
  </bpmndi:BPMNDiagram>
</bpmn:definitions>

If I add the moddle options

moddleOptions: {
    camunda: require('camunda-bpmn-moddle/resources/camunda')
  }

the extension properties stop working I get something like this

image

Always try to execute a service "undefined"

How to change the state from a UserTask

Hi,
I have defined variables in the engine execution:

this.engine.execute({
  variables: this.variables,
  listener: this.listener,
}, (err, definition) => {
  if (err) throw err;
  definition.once('end', () => {
      this.emit('finished')
  })
})

I have been able to reach this variables from the user task when I catch the wait event but I can see how to modify these variables in javascript

this.listener.on('wait', (activity) => {
   if (activity.type === 'bpmn:UserTask') {
     // how to change the content of the current state?
   }
})

Using the signal method, I can add new variables like this one taskInput: { UserTask_4: { clicks: 1 } } }. But I don't see how to update existing variables.

Can you explain me how to achieve this operation?

Get result from EndEvent block

Hello! I have new noob question :) . How can I get result of script execution on end event? I mean that I want to set Input parameters on EndEvent block:

2017-04-20 11 58 17

And what I should to do to get all Input parameters and values of end block (variables.temp is example, can be anything else)?

listener.on('leave', (task) => {
    if (task.type === 'bpmn:EndEvent') {
      resolve({
        type: 'end',
        result: ... <-- How to get all input parameters and values of EndEvent block?
      })
      engine.stop();
    }
});

is there any callback when the engine is on a stable state?

2

Hi, author
please see the above bpmn, 4 tasks execute parallel, and the script task will cost a long time to execute. So my problem is how could I know the engine is not executing some task, so that I can get state and do data persistence.

Let me explain it more clearly.
At beginning, 3 task execute parallel, userTask1, userTask2, scriptTask1.
And I already know userTask1 and userTask2 is waiting for signal by listen the wait event.
But for the scriptTask1, I can't simply listen on the end event of scriptTask1, because there may be new tasks behaind it. So when the end event is triggered, I can't do data persistence if there is a scriptTask2 behind scriptTask1. And I can't simply listen for the userTask as well, because the scriptTask will cost a long time.

So is there a callback or a event or something similar to trigger my application that the engine is now on a stable state?

Bpmn.Transformer.transform example is wrong on readme

const Bpmn = require('bpmn-engine');

const processXml = `
<?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <process id="theProcess" isExecutable="true">
    <startEvent id="theStart" />
    <userTask id="userTask" />
    <endEvent id="theEnd" />
    <sequenceFlow id="flow1" sourceRef="theStart" targetRef="userTask" />
    <sequenceFlow id="flow2" sourceRef="userTask" targetRef="theEnd" />
  </process>
</definitions>`;

- Bpmn.Transformer(processXml, {
+ Bpmn.Transformer.transform(processXml, {
  camunda: require('camunda-bpmn-moddle/resources/camunda')
}, (err, def, moddleContext) => {
  const engine = new Bpmn.Engine({
    context: moddleContext
  });

  engine.execute({
    variables: {
      shortid: '42'
    }
  }, (err, instance) => {
    console.log('Process instance started with id', instance.variables.shortid);
  });
});

serviceTask element always try to execute undefined

Here is the bpmn definition

<?xml version="1.0" encoding="UTF-8"?>
<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" id="Definitions_1" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="1.6.0">
  <bpmn:process id="Send_Mail_Process" isExecutable="true">
    <bpmn:startEvent id="startEvent">
      <bpmn:outgoing>SequenceFlow_1</bpmn:outgoing>
    </bpmn:startEvent>
    <bpmn:sequenceFlow id="SequenceFlow_1" sourceRef="startEvent" targetRef="sendEmail_1" />
    <bpmn:endEvent id="endEvent">
      <bpmn:incoming>SequenceFlow_1sxkbig</bpmn:incoming>
    </bpmn:endEvent>
    <bpmn:sequenceFlow id="SequenceFlow_2" sourceRef="sendEmail_1" targetRef="anotherTasks" />
    <bpmn:serviceTask id="sendEmail_1" name="send mail" camunda:asyncBefore="true">
      <bpmn:extensionElements>
        <camunda:connector>
          <camunda:inputOutput>
            <camunda:inputParameter name="emailAddress" />
            <camunda:outputParameter name="messageId" />
          </camunda:inputOutput>
          <camunda:connectorId>send-email</camunda:connectorId>
        </camunda:connector>
        <camunda:inputOutput>
          <camunda:inputParameter name="emailAddress" />
          <camunda:outputParameter name="messageId" />
        </camunda:inputOutput>
      </bpmn:extensionElements>
      <bpmn:incoming>SequenceFlow_1</bpmn:incoming>
      <bpmn:outgoing>SequenceFlow_2</bpmn:outgoing>
    </bpmn:serviceTask>
    <bpmn:task id="anotherTasks" name="Another tasks">
      <bpmn:incoming>SequenceFlow_2</bpmn:incoming>
      <bpmn:outgoing>SequenceFlow_1sxkbig</bpmn:outgoing>
    </bpmn:task>
    <bpmn:sequenceFlow id="SequenceFlow_1sxkbig" sourceRef="anotherTasks" targetRef="endEvent" />
  </bpmn:process>
  <bpmndi:BPMNDiagram id="BPMNDiagram_1">
    <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Send_Mail_Process">
      <bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="startEvent">
        <dc:Bounds x="173" y="102" width="36" height="36" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNEdge id="SequenceFlow_16m9goq_di" bpmnElement="SequenceFlow_1">
        <di:waypoint xsi:type="dc:Point" x="209" y="120" />
        <di:waypoint xsi:type="dc:Point" x="306" y="120" />
        <bpmndi:BPMNLabel>
          <dc:Bounds x="258" y="105" width="0" height="0" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNShape id="EndEvent_05uol1y_di" bpmnElement="endEvent">
        <dc:Bounds x="727" y="102" width="36" height="36" />
        <bpmndi:BPMNLabel>
          <dc:Bounds x="745" y="138" width="0" height="0" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNEdge id="SequenceFlow_17uu38n_di" bpmnElement="SequenceFlow_2">
        <di:waypoint xsi:type="dc:Point" x="406" y="120" />
        <di:waypoint xsi:type="dc:Point" x="501" y="120" />
        <bpmndi:BPMNLabel>
          <dc:Bounds x="454" y="105" width="0" height="0" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNShape id="ServiceTask_17vog4b_di" bpmnElement="sendEmail_1">
        <dc:Bounds x="306" y="80" width="100" height="80" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="Task_1fe5nu0_di" bpmnElement="anotherTasks">
        <dc:Bounds x="500.7078109932497" y="80" width="100" height="80" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNEdge id="SequenceFlow_1sxkbig_di" bpmnElement="SequenceFlow_1sxkbig">
        <di:waypoint xsi:type="dc:Point" x="601" y="120" />
        <di:waypoint xsi:type="dc:Point" x="727" y="120" />
        <bpmndi:BPMNLabel>
          <dc:Bounds x="664" y="95" width="0" height="0" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNEdge>
    </bpmndi:BPMNPlane>
  </bpmndi:BPMNDiagram>
</bpmn:definitions>

image

Always throws TypeError: Cannot read property 'module' of undefined

What can be wrong?

How to install run this project

Type: Documentation

Please document how to run, install.
I checked package.json to find "start" in "scripts".

Can someone help

multiInstance Subprocess just take the first item

I have a process with a sub process, i dont know the reason why jus take the fist item of the collection and then ends the loop

## Workflow

<?xml version="1.0" encoding="UTF-8"?>
<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="Definitions_1" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="1.6.0">
  <bpmn:process id="Process_1" name="ECN_Alert" isExecutable="true">
    <bpmn:serviceTask id="checkKeyword" name="Check records with keyword">
      <bpmn:extensionElements>
        <camunda:properties>
          <camunda:property name="service" value="dummy" />
        </camunda:properties>
        <camunda:inputOutput>
          <camunda:inputParameter name="url">mongodb://localhost/jane_document</camunda:inputParameter>
          <camunda:inputParameter name="table">documents</camunda:inputParameter>
          <camunda:inputParameter name="keywords">
            <camunda:map>
              <camunda:entry key="column">name</camunda:entry>
              <camunda:entry key="keyword">Urgent</camunda:entry>
              <camunda:entry key="operator">like</camunda:entry>
            </camunda:map>
          </camunda:inputParameter>
          <camunda:inputParameter name="dummy">
            <camunda:script scriptFormat="javascript"><![CDATA[[
 [
  { userId: 20, username: 'rkmax', email: 'rkmax@example', mobileNr: '+123456789' },
  { userId: 35, username: 'paed01', email: 'paed01@example', mobileNr: '+123456799' },
  { userId: 46, username: 'acabrera04', email: 'acabrera@example', mobileNr: '+123456709' }
]
]]]></camunda:script>
          </camunda:inputParameter>
          <camunda:outputParameter name="records">${result[0]}</camunda:outputParameter>
        </camunda:inputOutput>
      </bpmn:extensionElements>
      <bpmn:incoming>SequenceFlow_1hfi6b8</bpmn:incoming>
      <bpmn:incoming>SequenceFlow_1h7sr5l</bpmn:incoming>
      <bpmn:outgoing>SequenceFlow_new_records</bpmn:outgoing>
      <bpmn:outgoing>SequenceFlow_no_records</bpmn:outgoing>
    </bpmn:serviceTask>
    <bpmn:sequenceFlow id="SequenceFlow_1hfi6b8" sourceRef="StartEvent_1" targetRef="checkKeyword" />
    <bpmn:subProcess id="SubProcess_0ejq0my" name="ECN Alert">
      <bpmn:extensionElements>
        <camunda:inputOutput>
          <camunda:inputParameter name="itema">${variables.item}</camunda:inputParameter>
        </camunda:inputOutput>
      </bpmn:extensionElements>
      <bpmn:incoming>SequenceFlow_new_records</bpmn:incoming>
      <bpmn:outgoing>SequenceFlow_1urzsh8</bpmn:outgoing>
      <bpmn:multiInstanceLoopCharacteristics isSequential="true" camunda:collection="${variables.records}" />
      <bpmn:sequenceFlow id="SequenceFlow_127mgc7" sourceRef="createEvent" targetRef="sendAlert" />
      <bpmn:serviceTask id="createEvent" name="Create Alert">
        <bpmn:extensionElements>
          <camunda:inputOutput>
            <camunda:inputParameter name="name">ECN Alert</camunda:inputParameter>
            <camunda:inputParameter name="subject">
              <camunda:script scriptFormat="javascript"><![CDATA['ECN Alert from ' + this.variables.customer.username]]></camunda:script>
            </camunda:inputParameter>
            <camunda:inputParameter name="timestamp">
              <camunda:script scriptFormat="javascript">(new Date())</camunda:script>
            </camunda:inputParameter>
          </camunda:inputOutput>
          <camunda:properties>
            <camunda:property name="service" value="dummy" />
          </camunda:properties>
        </bpmn:extensionElements>
        <bpmn:incoming>SequenceFlow_0eqxdn8</bpmn:incoming>
        <bpmn:outgoing>SequenceFlow_127mgc7</bpmn:outgoing>
      </bpmn:serviceTask>
      <bpmn:serviceTask id="sendAlert" name="Send message">
        <bpmn:extensionElements>
          <camunda:field name="service">          <camunda:string>sendSMS</camunda:string>
</camunda:field>
          <camunda:inputOutput>
            <camunda:inputParameter name="body">ECN Alert - Tata Project 12</camunda:inputParameter>
            <camunda:inputParameter name="from">+19374018810</camunda:inputParameter>
            <camunda:inputParameter name="to">+16504229484</camunda:inputParameter>
          </camunda:inputOutput>
          <camunda:properties>
            <camunda:property name="service" value="dummy" />
          </camunda:properties>
        </bpmn:extensionElements>
        <bpmn:incoming>SequenceFlow_127mgc7</bpmn:incoming>
        <bpmn:outgoing>SequenceFlow_0mktnsy</bpmn:outgoing>
      </bpmn:serviceTask>
      <bpmn:sequenceFlow id="SequenceFlow_0eqxdn8" sourceRef="customerInfo" targetRef="createEvent" />
      <bpmn:serviceTask id="customerInfo" name="Get User data">
        <bpmn:extensionElements>
          <camunda:inputOutput>
            <camunda:inputParameter name="user_id">
              <camunda:script scriptFormat="javascript">this.variables.item[this.variables.index].userId</camunda:script>
            </camunda:inputParameter>
            <camunda:inputParameter name="dummy">
              <camunda:script scriptFormat="javascript">this.variables.item[this.variables.index]</camunda:script>
            </camunda:inputParameter>
            <camunda:outputParameter name="customer">${result[0]}</camunda:outputParameter>
          </camunda:inputOutput>
          <camunda:properties>
            <camunda:property name="service" value="dummy" />
          </camunda:properties>
        </bpmn:extensionElements>
        <bpmn:incoming>SequenceFlow_1j72bta</bpmn:incoming>
        <bpmn:outgoing>SequenceFlow_0eqxdn8</bpmn:outgoing>
      </bpmn:serviceTask>
      <bpmn:endEvent id="EndEvent_066banc">
        <bpmn:incoming>SequenceFlow_0mktnsy</bpmn:incoming>
      </bpmn:endEvent>
      <bpmn:sequenceFlow id="SequenceFlow_0mktnsy" sourceRef="sendAlert" targetRef="EndEvent_066banc" />
      <bpmn:startEvent id="StartEvent_1u4gdfz">
        <bpmn:outgoing>SequenceFlow_1j72bta</bpmn:outgoing>
      </bpmn:startEvent>
      <bpmn:sequenceFlow id="SequenceFlow_1j72bta" sourceRef="StartEvent_1u4gdfz" targetRef="customerInfo" />
    </bpmn:subProcess>
    <bpmn:intermediateCatchEvent id="IntermediateThrowEvent_1b0httn">
      <bpmn:incoming>SequenceFlow_no_records</bpmn:incoming>
      <bpmn:outgoing>SequenceFlow_1h7sr5l</bpmn:outgoing>
      <bpmn:timerEventDefinition>
        <bpmn:timeDuration xsi:type="bpmn:tFormalExpression">PT10S</bpmn:timeDuration>
      </bpmn:timerEventDefinition>
    </bpmn:intermediateCatchEvent>
    <bpmn:sequenceFlow id="SequenceFlow_1h7sr5l" sourceRef="IntermediateThrowEvent_1b0httn" targetRef="checkKeyword" />
    <bpmn:sequenceFlow id="SequenceFlow_new_records" name="New records&#10;&#10;" sourceRef="checkKeyword" targetRef="SubProcess_0ejq0my">
      <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression" language="javascript"><![CDATA[this.variables.records.length > 0]]></bpmn:conditionExpression>
    </bpmn:sequenceFlow>
    <bpmn:startEvent id="StartEvent_1">
      <bpmn:outgoing>SequenceFlow_1hfi6b8</bpmn:outgoing>
    </bpmn:startEvent>
    <bpmn:sequenceFlow id="SequenceFlow_no_records" name="No records&#10;&#10;" sourceRef="checkKeyword" targetRef="IntermediateThrowEvent_1b0httn">
      <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression" language="javascript">this.variables.records.length === 0</bpmn:conditionExpression>
    </bpmn:sequenceFlow>
    <bpmn:endEvent id="EndEvent_1c4pv9o">
      <bpmn:incoming>SequenceFlow_1urzsh8</bpmn:incoming>
    </bpmn:endEvent>
    <bpmn:sequenceFlow id="SequenceFlow_1urzsh8" sourceRef="SubProcess_0ejq0my" targetRef="EndEvent_1c4pv9o" />
    <bpmn:textAnnotation id="TextAnnotation_1pra9kr">    <bpmn:text>Wait 10 Seconds</bpmn:text>
</bpmn:textAnnotation>
    <bpmn:association id="Association_1doxeqj" sourceRef="IntermediateThrowEvent_1b0httn" targetRef="TextAnnotation_1pra9kr" />
  </bpmn:process>
  <bpmndi:BPMNDiagram id="BPMNDiagram_1">
    <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Process_1">
      <bpmndi:BPMNShape id="ServiceTask_02n31yf_di" bpmnElement="checkKeyword">
        <dc:Bounds x="252" y="284" width="100" height="80" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNEdge id="SequenceFlow_1hfi6b8_di" bpmnElement="SequenceFlow_1hfi6b8">
        <di:waypoint xsi:type="dc:Point" x="210" y="324" />
        <di:waypoint xsi:type="dc:Point" x="252" y="324" />
        <bpmndi:BPMNLabel>
          <dc:Bounds x="231" y="309" width="0" height="0" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNShape id="SubProcess_0ejq0my_di" bpmnElement="SubProcess_0ejq0my" isExpanded="true">
        <dc:Bounds x="421" y="370" width="596" height="170" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNEdge id="SequenceFlow_127mgc7_di" bpmnElement="SequenceFlow_127mgc7">
        <di:waypoint xsi:type="dc:Point" x="755" y="471" />
        <di:waypoint xsi:type="dc:Point" x="800" y="471" />
        <bpmndi:BPMNLabel>
          <dc:Bounds x="778" y="456" width="0" height="0" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNShape id="IntermediateCatchEvent_1vvo8n5_di" bpmnElement="IntermediateThrowEvent_1b0httn">
        <dc:Bounds x="479" y="306" width="36" height="36" />
        <bpmndi:BPMNLabel>
          <dc:Bounds x="497" y="342" width="0" height="0" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="TextAnnotation_1pra9kr_di" bpmnElement="TextAnnotation_1pra9kr">
        <dc:Bounds x="539" y="239" width="100" height="30" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNEdge id="SequenceFlow_1h7sr5l_di" bpmnElement="SequenceFlow_1h7sr5l">
        <di:waypoint xsi:type="dc:Point" x="497" y="306" />
        <di:waypoint xsi:type="dc:Point" x="497" y="225" />
        <di:waypoint xsi:type="dc:Point" x="302" y="225" />
        <di:waypoint xsi:type="dc:Point" x="302" y="284" />
        <bpmndi:BPMNLabel>
          <dc:Bounds x="400" y="210" width="0" height="0" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="SequenceFlow_1g4ux2g_di" bpmnElement="SequenceFlow_new_records">
        <di:waypoint xsi:type="dc:Point" x="302" y="364" />
        <di:waypoint xsi:type="dc:Point" x="302" y="455" />
        <di:waypoint xsi:type="dc:Point" x="421" y="455" />
        <bpmndi:BPMNLabel>
          <dc:Bounds x="226" y="410" width="62" height="12" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNShape id="StartEvent_1kefkpm_di" bpmnElement="StartEvent_1">
        <dc:Bounds x="174" y="306" width="36" height="36" />
        <bpmndi:BPMNLabel>
          <dc:Bounds x="192" y="342" width="0" height="0" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="ServiceTask_02j18g4_di" bpmnElement="createEvent">
        <dc:Bounds x="655" y="432" width="100" height="80" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="ServiceTask_1b633sz_di" bpmnElement="sendAlert">
        <dc:Bounds x="800" y="430" width="100" height="80" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNEdge id="SequenceFlow_0eqxdn8_di" bpmnElement="SequenceFlow_0eqxdn8">
        <di:waypoint xsi:type="dc:Point" x="617" y="472" />
        <di:waypoint xsi:type="dc:Point" x="655" y="472" />
        <bpmndi:BPMNLabel>
          <dc:Bounds x="636" y="457" width="0" height="0" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNShape id="ServiceTask_1n9utwm_di" bpmnElement="customerInfo">
        <dc:Bounds x="517" y="432" width="100" height="80" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNEdge id="SequenceFlow_17uz6i6_di" bpmnElement="SequenceFlow_no_records">
        <di:waypoint xsi:type="dc:Point" x="352" y="324" />
        <di:waypoint xsi:type="dc:Point" x="479" y="324" />
        <bpmndi:BPMNLabel>
          <dc:Bounds x="390" y="299" width="54" height="12" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNShape id="EndEvent_1c4pv9o_di" bpmnElement="EndEvent_1c4pv9o">
        <dc:Bounds x="1136" y="437" width="36" height="36" />
        <bpmndi:BPMNLabel>
          <dc:Bounds x="1154" y="473" width="0" height="0" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNEdge id="SequenceFlow_1urzsh8_di" bpmnElement="SequenceFlow_1urzsh8">
        <di:waypoint xsi:type="dc:Point" x="1017" y="455" />
        <di:waypoint xsi:type="dc:Point" x="1136" y="455" />
        <bpmndi:BPMNLabel>
          <dc:Bounds x="1077" y="430" width="0" height="0" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Association_1doxeqj_di" bpmnElement="Association_1doxeqj">
        <di:waypoint xsi:type="dc:Point" x="511" y="313" />
        <di:waypoint xsi:type="dc:Point" x="569" y="269" />
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNShape id="EndEvent_066banc_di" bpmnElement="EndEvent_066banc">
        <dc:Bounds x="943" y="454" width="36" height="36" />
        <bpmndi:BPMNLabel>
          <dc:Bounds x="961" y="490" width="0" height="0" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNEdge id="SequenceFlow_0mktnsy_di" bpmnElement="SequenceFlow_0mktnsy">
        <di:waypoint xsi:type="dc:Point" x="900" y="471" />
        <di:waypoint xsi:type="dc:Point" x="943" y="472" />
        <bpmndi:BPMNLabel>
          <dc:Bounds x="922" y="457" width="0" height="0" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNShape id="StartEvent_1u4gdfz_di" bpmnElement="StartEvent_1u4gdfz">
        <dc:Bounds x="448" y="452" width="36" height="36" />
        <bpmndi:BPMNLabel>
          <dc:Bounds x="466" y="488" width="0" height="0" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNEdge id="SequenceFlow_1j72bta_di" bpmnElement="SequenceFlow_1j72bta">
        <di:waypoint xsi:type="dc:Point" x="484" y="470" />
        <di:waypoint xsi:type="dc:Point" x="517" y="471" />
        <bpmndi:BPMNLabel>
          <dc:Bounds x="501" y="456" width="0" height="0" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNEdge>
    </bpmndi:BPMNPlane>
  </bpmndi:BPMNDiagram>
</bpmn:definitions>

## Code

const Bpmn = require('bpmn-engine');
const sourceXml = "..." // workflow;
const engine = new Bpmn.Engine({
  source       : sourceXml,
  moddleOptions: {
    camunda: require('camunda-bpmn-moddle/resources/camunda')
  }
});

engine.execute({
  services : {
    dummy: (executionContext, serviceCallback) => {
      const result = executionContext['dummy'] || ['dummy'];

      serviceCallback(null, result);
    }
  },
  variables: {}
}, (err, instance) => {
  if (err) return console.log(err);
  instance.once('end', () => {
    console.log('instance process');
  });
});

Are output variables from service calls aren't treated like arrays anymore?

Hi @paed01 long time without speak(write)

this week I've restarted my work with the BPMN and migrated my project to version 3.0, a nice surprise to see that only a couple of lines was needed in order to upgrade (I was using 1.2.0 😅 )

one thing I noticed, it's when defining output parameters they are not wrapped anymore as an array. example on the version 1.x I did my service definition like follows

serviceCallback(error, [{nick: 'rkmax'}, {nick: 'paed01'}])

and later on my XML I can define the output like

<camunda:outputParameter name="userNicks">${result[0]}</camunda:outputParameter>

Now I found that If I execute the previous expression I got the first element of the result instead the whole array (I want the array). If this behavior is correct then this example it's possibly wrong

Btw, nice job with all the new stuff

How to extract extension elements from BPMN.

Hi,
I have a BPMN file created using the cammunda modeler (provides the extension elements )
sample.txt

How to extract the BPMN elements, and could you also suggest what is the best way to traverse through each task and get the next task ( as in a graph ). The definition returned by the engine gives a list of elementsByID (ModdleElements), I can traverse that and get the outgoing elements and proceed. Is there any other better way.?

After update to 2.x executionContext.variables is not available anymore to my services

I have updated to 2.1.0 but the following variables are not available for my services

  • executionContext.variables
  • executionContext.services

Example

function dummy(executionContext, serviceCallback) {
  debug('dummy add-on was called', executionContext);
  debug(executionContext.variables); // undefined
  debug(executionContext.services); // undefined
  serviceCallback(null, ['dummy']);
}

How to correctly resume state?

Hello, I created small sample diagram and script, that must resume execution of diagram if it unexpectedly stops. But in fact it executes only last block and stops whole script. Please help, what I'm doing wrong?

2017-03-20 11 34 51

Normal execution, without interrupt ( with debug )

~ node index.js
START Test process
START Start
START Task A
START Task B
Waiting Task B for 5 seconds...
START Parallel 2
Resume Task B!
START Task C
Script completed

Execution with interrupt on Task B ( with debug ) :

~ node index.js
START Test process
START Start
START Task A
START Task B
Waiting Task B for 5 seconds...
START Parallel 2
^C

~ node index.js
Resuming saved state
START Task B
Waiting Task B for 5 seconds...
Resume Task B!
START Parallel 2

Code:
index.js and Services.json

Diagram:
diagram_1.bpmn

engine.getState() output when I interrupted execution by ^C:
state.json

define variables through the execution

Hi,

is it possible to define any variable through the execution? I didn't found any examples or similar for the definition of variables in connection with the resume method.

So i want to resume the engine for example with some decision parameters. The only way i found is to define it over the execution context like:

let engine = BpmnEngineClass.Engine.resume(state,
      {
        listener: listener,
        variables: { choosenTaskId: "UserId123" } // this doesnt work for me is that normally?
      },
      (err: any, execution: any) => {       
        execution.mainProcess.parentContext.variables = { choosenTaskId: "UserId123" }; //  works 
        if (err) {
          console.log(err);
          reject(err);
        }
      }
    );

would be great if you could give any advice to solve this.

Handle multiple versions of a process

If I start a process with one version of the process and then update the process, the current running processes should still use old version.
If you know what I mean :)

Does this lib work with Angular 5?

Hi everyone,

Does anyone get this lib work with Angular 5 in browser? If someone does, could you please shed some light on it?

Thanks

Strange step by step execution

Hello, I wrote small script that executes BPMN process by steps, and logs «start» and «leave» events.
But I have two issues:
(1) leaving from block appears after than next block's start event. Is it normal?
(2) To be clear, my project must executes in parallel many BPMN process and I start it by queue, that in each step execute 1-3 blocks from BPMN scheme, save state to storage and stop engine. I found that for me it better case to parallel execution of many long time (up to mounths) processes. In this case I also have trouble that sometimes I execute block two times, because it executes after engine stoped. How can I prevent this?

All sources in attach. Running node index.js, cleaning cache after execution rm data/*
bpmn_engine.zip

Start step
start Process_1
start Start
start fetch <--- (2) here engine stoping
End of step <---(2) here engine stoped
FETCH SEND <---(2) but it executes block!
Start step
start fetch <--- (1)
FETCH SEND <---(2) and executes second time in next step
FETCH RECEIVE
FETCH RECEIVE
start ExclusiveGateway_18cywiu <--- (1)
leave fetch <--- (1)
start parser
End of step
Start step
start parser
start logWeather
Current weather in Kazan: 4
leave parser
start ExclusiveGateway_0c57ix8
End of step
Start step
start ExclusiveGateway_0c57ix8
leave ExclusiveGateway_0c57ix8
start parallel1
start ParallelTask1
End of step
Start step
start ParallelTask1
start parallel1
start ParallelTask2
End of step
Start step
start ParallelTask2
start parallel2
leave ParallelTask2

Blocking and Persistence

I apologize for opening an issue with this question but I couldn't find another way to contact you. I have a potential project where the client is asking for a node.js based BPMN engine. The use case is an embedded processor with limited resource so a JVM is out of the question.
Your JS engine looks to have most of what they say is needed but I'm not sure about running multiple process instances against the one engine. Will the engine block on activities? Also, is it possible to deploy updated process definitions?

Really hope this is a fit, but dont want to recommend without understanding the above details.
thanks,
Greg

engine.getPendingActivities() return unexpected result.

hi author,
engine.getPendingActivities() get unexpected return, the following is my test script

'use strict';

const Bpmn = require('bpmn-engine');
const EventEmitter = require('events').EventEmitter;
const fs = require('fs');
let enginestate = null;

// const processXml = fs.readFileSync(__dirname + '/resources/parallel-gateway.bpmn', 'utf-8');
const processXml = `
    <?xml version="1.0" encoding="UTF-8"?>
<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="Definitions_1" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="1.6.0">
  <bpmn:process id="Process_1" isExecutable="true">
    <bpmn:startEvent id="StartEvent_1">
      <bpmn:outgoing>SequenceFlow_0lb50jr</bpmn:outgoing>
    </bpmn:startEvent>
    <bpmn:sequenceFlow id="SequenceFlow_0lb50jr" sourceRef="StartEvent_1" targetRef="ExclusiveGateway_1huvwfm" />
    <bpmn:parallelGateway id="ExclusiveGateway_1huvwfm">
      <bpmn:incoming>SequenceFlow_0lb50jr</bpmn:incoming>
      <bpmn:outgoing>SequenceFlow_1t5xyuf</bpmn:outgoing>
      <bpmn:outgoing>SequenceFlow_0sb9gi3</bpmn:outgoing>
    </bpmn:parallelGateway>
    <bpmn:sequenceFlow id="SequenceFlow_1t5xyuf" sourceRef="ExclusiveGateway_1huvwfm" targetRef="t_a" />
    <bpmn:sequenceFlow id="SequenceFlow_0sb9gi3" sourceRef="ExclusiveGateway_1huvwfm" targetRef="t_b" />
    <bpmn:sequenceFlow id="SequenceFlow_167zujm" sourceRef="t_b" targetRef="ExclusiveGateway_0xb7xzm" />
    <bpmn:parallelGateway id="ExclusiveGateway_0xb7xzm">
      <bpmn:incoming>SequenceFlow_167zujm</bpmn:incoming>
      <bpmn:incoming>SequenceFlow_0ombfuh</bpmn:incoming>
      <bpmn:outgoing>SequenceFlow_00feimj</bpmn:outgoing>
    </bpmn:parallelGateway>
    <bpmn:sequenceFlow id="SequenceFlow_0ombfuh" sourceRef="t_a" targetRef="ExclusiveGateway_0xb7xzm" />
    <bpmn:userTask id="t_a" name="task a">
      <bpmn:extensionElements>
        <camunda:formData>
          <camunda:formField id="a" type="string" />
        </camunda:formData>
        <camunda:inputOutput>
          <camunda:outputParameter name="m_a">
            <camunda:script scriptFormat="javascript">this.a</camunda:script>
          </camunda:outputParameter>
        </camunda:inputOutput>
      </bpmn:extensionElements>
      <bpmn:incoming>SequenceFlow_1t5xyuf</bpmn:incoming>
      <bpmn:outgoing>SequenceFlow_0ombfuh</bpmn:outgoing>
    </bpmn:userTask>
    <bpmn:userTask id="t_b" name="task b">
      <bpmn:extensionElements>
        <camunda:formData>
          <camunda:formField id="b" type="string" />
        </camunda:formData>
        <camunda:inputOutput>
          <camunda:outputParameter name="m_b">
            <camunda:script scriptFormat="javascript">this.b</camunda:script>
          </camunda:outputParameter>
        </camunda:inputOutput>
      </bpmn:extensionElements>
      <bpmn:incoming>SequenceFlow_0sb9gi3</bpmn:incoming>
      <bpmn:outgoing>SequenceFlow_167zujm</bpmn:outgoing>
    </bpmn:userTask>
    <bpmn:sequenceFlow id="SequenceFlow_00feimj" sourceRef="ExclusiveGateway_0xb7xzm" targetRef="t_c" />
    <bpmn:endEvent id="EndEvent_138frla">
      <bpmn:incoming>SequenceFlow_092u6ac</bpmn:incoming>
    </bpmn:endEvent>
    <bpmn:sequenceFlow id="SequenceFlow_092u6ac" sourceRef="t_c" targetRef="EndEvent_138frla" />
    <bpmn:userTask id="t_c" name="task c">
      <bpmn:incoming>SequenceFlow_00feimj</bpmn:incoming>
      <bpmn:outgoing>SequenceFlow_092u6ac</bpmn:outgoing>
    </bpmn:userTask>
  </bpmn:process>
</bpmn:definitions>
`;

const engine = new Bpmn.Engine({
    name: 'user task example 1',
    moddleOptions: {
        camunda: require('camunda-bpmn-moddle/resources/camunda')
    },
    source: processXml
});
const listener = new EventEmitter();

listener.on('wait-t_a', (child, instance) => {
    // console.log(engine.getState());
    // instance.signal(child.activity.id, {
    //     a: 'aaaaaaaaaaaa'
    // });
});

listener.on('wait-t_b', (child, instance) => {
    // console.log(engine.getState());
    // instance.signal(child.activity.id, {
    //     b: 'bbbbbbbbbbbbb'
    // });
});

engine.on('end', (task, instance) => {
    console.log(`engine is completed`);
});

engine.execute({
    listener: listener
}, (err, instance) => {
    if (err) throw err;
});


setTimeout(function () {
    enginestate = engine.getState();
    console.log(enginestate);

    let listener_1 = new EventEmitter();
    let engine_1 = Bpmn.Engine.resume(enginestate, {
        listener: listener_1
    });

    listener_1.on('wait-t_b', (task, instance) => {
        // console.log(engine_1.getState());
        let pendings = engine_1.getPendingActivities();
        console.log(pendings.definitions[0]);
        // instance.signal(task.activity.id, {
            // b: 'aaaaaaaaaaaaaa'
        // });
    });

    listener_1.on('wait-t_a', (task, instance) => {
        // console.log(engine_1.getState());
        let pendings = engine_1.getPendingActivities();
        console.log(pendings.definitions[0]);
        // instance.signal(task.activity.id, {
            // a: 'aaaaaaaaaaaaaa'
        // });
    });

    listener_1.on('wait-t_c', (task, instance) => {
        console.log('wait t_c');
        let pendings = engine_1.getPendingActivities();
        console.log(pendings.definitions[0]);
    })

    engine_1.on('end', (task, instance) => {
        console.log(`engine is end`);
    })

}, 2000);

Event timestamp and order for creating a history

I am currently writing some history functionality and ran into an issue with the event listener execution order and the process execution order.

Consider the example process from the documentation:

const processXml = `
<?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <process id="theProcess" isExecutable="true">
    <startEvent id="theStart" />
    <userTask id="userTask" />
    <endEvent id="theEnd" />
    <sequenceFlow id="flow1" sourceRef="theStart" targetRef="userTask" />
    <sequenceFlow id="flow2" sourceRef="userTask" targetRef="theEnd" />
  </process>
</definitions>`;

When listening to every event using .on (regardless of type, so only start, end, wait and so on) I get for the above process the following order using console.log(instance.id, 'eventName', element.type, element.id):

I20180308-20:52:48.480(1)? theProcess start bpmn:Process theProcess
I20180308-20:52:48.481(1)? theProcess enter bpmn:StartEvent theStart
I20180308-20:52:48.482(1)? theProcess start bpmn:StartEvent theStart
I20180308-20:52:48.482(1)? theProcess end bpmn:StartEvent theStart
I20180308-20:52:48.490(1)? theProcess enter bpmn:UserTask userTask
I20180308-20:52:48.491(1)? theProcess start bpmn:UserTask userTask
I20180308-20:52:48.491(1)? theProcess end bpmn:UserTask userTask
I20180308-20:52:48.492(1)? theProcess wait bpmn:UserTask userTask
I20180308-20:52:48.493(1)? theProcess taken' bpmn:SequenceFlow flow1
I20180308-20:52:48.493(1)? theProcess leave bpmn:StartEvent theStart
I20180308-20:52:48.493(1)? theProcess enter bpmn:EndEvent theEnd
I20180308-20:52:48.494(1)? theProcess end bpmn:EndEvent theEnd
I20180308-20:52:48.494(1)? theProcess taken' bpmn:SequenceFlow flow2
I20180308-20:52:48.495(1)? theProcess leave bpmn:UserTask userTask
I20180308-20:52:48.495(1)? theProcess leave bpmn:EndEvent theEnd

Of course the events are not always in order due to the async implementation. Is there something like a timeStamp or anything else I can use to get the correct execution sequence without traversing and checking against the moddle?

By the way, shouldn't also there be an end event be fired for the bpmn:Process ?

Contact information request

Hi,

Me and my college at TUI just met with @rolu01 and we are considering switching to this project from our current bpmn engine and would like to get in touch with you for a short discussion on the future direction of the project.

If you have a moment to spare, please reach out us on the following email:
[email protected]

using form-data cause unexpected exception

Hi, author, thanks for your great work.
I'm trying to use Forms for UserTask. Camunda-modeler suppports two kinds of Form Type, form-key and form-data. If I didn't specify any Form Fields when using form-data, an exception will happened. It seems that in the lib/activities/Form.js, function initFields and getState use undefined property this.formData.fields (which is because I didn't specify any form field).

And, I'm confused if a form-data type Form must specify the form field? It seems that the engine didn't care what the field is, and I can send any form-data regardless the form fields at listener.

So, I recommend to make the engine check the form field strong type, only fields defined at bpmn file are initialized, and during the execution, undeclared form field will not be parsed.

remove ModdleContext in state

Hi author,
when I use getState(), the state contains a big object moddleContext, which I think is not necessary in the state. i.e., the state should only contain data and all activities' state.

I reviewed your code, the moddleContext would not be changed during the lifetime of a bpmn execution. So the moddleContext should be considered redundant and be removed from state.

and for resume, maybe the content of bpmn file should be passed as a parameter.

inputParameter of the type map always are passed as undefined

<bpmn:serviceTask id="something_1" name="Do something">
<bpmn:extensionElements>
  <camunda:inputOutput>
    <camunda:inputParameter name="name">Jhon</camunda:inputParameter>
      <camunda:inputParameter name="keywords">
        <camunda:map>
        <camunda:entry key="status">online</camunda:entry>
        </camunda:map>
      </camunda:inputParameter>
  </camunda:inputOutput>
  <camunda:properties>
    <camunda:property name="service" value="doSomethingServiceFn" />
  </camunda:properties>
</bpmn:extensionElements>

When the service is called I got

{
  "name": "Jhon",
  "keywords": undefined
}

subprocess

Can you give an subprocess example, struggled... ..

How to move a "resumed" engine forward in a flow

Hello,

Please, how can a persisted workflow proceed (continue execution) after it has be resumed, viz:

var engine = bpmn.Engine.resume(persistedState);

what's next? Will it be:

// engine.getPendingActivities() && "Look for '.entered || .waiting" && and signal/run
// or what please?

I'm looking at putting this behind an API to support a flow like:
start-->persist-->[waiting period, could be days]-->execute-->persist-->execute...-->end (at some point)

Thanks for this awesome framework!

activity enter question

the engine is awesome,but there's some question for the acitivity's enter,I don't understand why the acitivity will enter when it's inbond flow is discarded.what's the purpose for it?

discard(flow, rootFlow) { if (!this.entered) this.enter(flow); return this.discardAllOutbound(rootFlow); }

Could u draw us a quick roadmap ?

Hi Pål,
could u give us a light roadmap of the changes and enhancement you have in the pipe ?
A glimpse at the develop branch shows me that Environment are coming.... (breaking change, right?)
What else ?
Thanks very much and keep up, this project is pretty goooood ;)
/tm

Next is not defined

Hi ,
I just started creating workflow using bpmn-engine. I have created small process contains three activities start, service task and end. To execute the service task, I wrote the following script.

const engine = new bpmn.Engine({
name: 'execution example',
source: data,
moddleOptions: {
camunda: require('camunda-bpmn-moddle/resources/camunda')
}
});

engine.execute({
services: {
get: (context, next)=>{
console.log('Service executed');
next();
}
}});

engine.once('end', ()=>{
console.log('Completed');
});

I created the process by using the camunda modeler. In my bpmn file the xml will look like -
<bpmn:serviceTask id="Task_0y9j9el" name="scriptTask" camunda:expression="${services.get}" >
bpmn:incomingSequenceFlow_1may9fh</bpmn:incoming>
bpmn:outgoingSequenceFlow_1qsl60z</bpmn:outgoing>
</bpmn:serviceTask>

The problem is that there is an error as -

D:\Node\bpmn\bpmn-process-demo\app.js:72
next();
^

TypeError: next is not a function
at get (D:\Node\bpmn\bpmn-process-demo\app.js:72:9)
at String.replace (native)
at resolveExpressions (D:\Node\bpmn\bpmn-process-demo\node_modules\bpmn-engi
ne\lib\expressions.js:26:21)
at Object.execute (D:\Node\bpmn\bpmn-process-demo\node_modules\bpmn-engine\l
ib\tasks\ServiceTask.js:57:25)
at EventEmitter.ServiceTask.execute (D:\Node\bpmn\bpmn-process-demo\node_mod
ules\bpmn-engine\lib\tasks\ServiceTask.js:36:23)
at EventEmitter.BaseTask.run (D:\Node\bpmn\bpmn-process-demo\node_modules\bp
mn-engine\lib\activities\BaseTask.js:33:8)
at EventEmitter.internals.Activity.onInbound (D:\Node\bpmn\bpmn-process-demo
\node_modules\bpmn-engine\lib\activities\Activity.js:97:15)
at emitTwo (events.js:111:20)
at EventEmitter.emit (events.js:191:7)
at Immediate.setImmediate (D:\Node\bpmn\bpmn-process-demo\node_modules\bpmn-
engine\lib\activities\Flow.js:48:10)

Please guide me how can I create and execute different tasks.

why this engine can't load the xml files made by bpmn.io(bpmn-js tool)?

when i use bpmn define xml like following ,why this engine can not run ?

<bpmn:definitions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" id="Definitions_1" targetNamespace="http://bpmn.io/schema/bpmn">
<bpmn:process id="Process_1" isExecutable="false">
<bpmn:startEvent id="StartEvent_1" name="start">
bpmn:outgoingSequenceFlow_1fr4k13</bpmn:outgoing>
</bpmn:startEvent>
<bpmn:sequenceFlow id="SequenceFlow_1fr4k13" sourceRef="StartEvent_1" targetRef="Task_18jc3wy" />
<bpmn:manualTask id="Task_18jc3wy" name="task">
bpmn:incomingSequenceFlow_1fr4k13</bpmn:incoming>
bpmn:outgoingSequenceFlow_1bmylwu</bpmn:outgoing>
</bpmn:manualTask>
<bpmn:endEvent id="EndEvent_16xwvhs" name="end">
bpmn:incomingSequenceFlow_1bmylwu</bpmn:incoming>
</bpmn:endEvent>
<bpmn:sequenceFlow id="SequenceFlow_1bmylwu" sourceRef="Task_18jc3wy" targetRef="EndEvent_16xwvhs" />
</bpmn:process>
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Process_1">
<bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="StartEvent_1">
<dc:Bounds x="173" y="102" width="36" height="36" />
bpmndi:BPMNLabel
<dc:Bounds x="179" y="138" width="24" height="12" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="SequenceFlow_1fr4k13_di" bpmnElement="SequenceFlow_1fr4k13">
<di:waypoint x="209" y="120" />
<di:waypoint x="259" y="120" />
bpmndi:BPMNLabel
<dc:Bounds x="234" y="99" width="0" height="12" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNShape id="ManualTask_0we64bx_di" bpmnElement="Task_18jc3wy">
<dc:Bounds x="259" y="80" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="EndEvent_16xwvhs_di" bpmnElement="EndEvent_16xwvhs">
<dc:Bounds x="409" y="102" width="36" height="36" />
bpmndi:BPMNLabel
<dc:Bounds x="417" y="142" width="21" height="12" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="SequenceFlow_1bmylwu_di" bpmnElement="SequenceFlow_1bmylwu">
<di:waypoint x="359" y="120" />
<di:waypoint x="409" y="120" />
bpmndi:BPMNLabel
<dc:Bounds x="384" y="99" width="0" height="12" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</bpmn:definitions>

How to use boundary error events

Hi @paed01

I am trying to figure out how to use the boundary error event on a service task.
The "Task loop over collection" example seem to be the only one that contains this element but it would be nice to see an example on how to implement it from a code perspective.

My question is if I can attach code directly to the boundary event somehow or is it supposed to just pass on to the next activity where the error should be handled?

bug when add endEvent to exclusiveGateway

Hi, author
1

the bpmn above will not trigger the end event.
and if I add a blank task behind the exclusiveGateway, the end event is triggered.
I think this may be a bug of the engine.

2

BTW, maybe you should allow others to tag their issues?

External Resource for gateway conditionals

Hi,

I am just reviewing this library and looks great, well done :)

I have a workflow that uses an Exclusive gateway and from the examples and what i can tell from the code the only supported conditionals is javascript inline the bpmn xml file?

is there a way similar to the services, to reference a module and function for the condition?

Why ParallelGateway should skip discarded inbouds when joining?

First off, this library is awesome!

I have a question, due to me being a newbie in BPMN: why a parallel gateway should skip discarded inbouds when used as a join symbol? Is it a standard behavior of BPMN 2.0?

My use case: just before the joining parallel gateway, I have an exclusive one (X) with 2 outputs, one going straight to the joining parallel gateway, and the other going back for loop purpose.

Thanks!

Collection loop error

If task is marked as Sequential Multi Item and loop over collection is used, then it will not loop all elements in collection.

Can't define a Object as inputOutput parameter

Using
Name: sample
type: Script
Script format: Javascript
Scrip type: Inline Script
Script: {"keyword": "hello"}

Current value on executionContext

{sample:  "hello"}

Expected value on executionContext

{sample: {keyword: "hello"}}

Process instance state - persistance

Hi,
Does 'bpmn-engine' support any persistence for the process instances (DB, file-system)?
Is it there any API to query the process instance state?

br,
Vlad

How add services to resume?

can i add services to resume function?
similare listener
Bpmn.Engine.resume(state, { listener: listener});
problem?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.