BPM Engine
BPM Engine is a BPMN workflow execution engine written in JavaScript.
Install and use
$ npm install bpm-engine --save
Use the BPM Engine with Node.JS or in your favourite Browser.
Start a processInstance
const BPMEngine = ; // Instantiate an engineconst bpm = ; // Create a new process instance, specify a valid bpmn definition (returns a token)const token = await bpm ; // Tell the initial token to continue executionawait token;
Continue execution of a processInstance (by token)
// At some later point in time, in a different part of// your app (e.g. when a User task is handled as complete by your own app)const token = await bpm; await token;
Currently supported flow objects
Events:
- Start
- End
- IntermediateThrow
- MessageIntermediateThrow
- MessageIntermediateCatch
- MessageEnd
- TimerIntermediateCatch
- EscalationIntermediateThrow
- EscalationEnd
- ErrorEnd
- ConditionalIntermediateThrow
- LinkIntermediateCatch
- LinkIntermediateThrow
- CompensationIntermediateThrow
- CompensationEnd
- SignalIntermediateThrow
- SignalIntermediateCatch
- MessageStart
- TimerStart
- ConditionalStart
- SignalStart
- SignalEnd
- TerminateEnd
Activities:
- Task
- Service
- User
- Manual
- Send
- Receive
- BusinessRule
- Script
Gateways:
- Exclusive
- Inclusive
- Parallel
- EventBased
- Complex
Other:
- Swimlanes
- CallActivity
- SubProcess
- Loop
- ParallelMultiInstance
- SequentialMultiInstance
Persistency layer
You can install the following package to add a persistency layer to the state of your processes.
- bpm-engine-persist-mongoose
Use one of the persistency plugins in the BPM Engine:
const BPMEngine = ;const PersistMongoose = ; const persistMongoose = '<mongodb:url>' mongooseConnectionOptions; const engine = persist: persistMongoose;
Develop your own plugins
Currently you can develop plugins for the following elements:
- Element
- UserTask
- ServiceTask
You create plugins by extending from one of the above classes and instantiating a class into the plugins array when instantiating the engine.
const BPMEngine = ; PluginsElement { super; thisstore = store; } { thisstore; }; { thisstore; }; { thisstore; }; const history = ; const engine = plugins: history ;
The above plugin will push executed element's id's into an array, which serves as some kind of log.
Plugin methods
Every plugin can make use of three methods which will be called in order of execution, onReady, onActive and onComplete.
Method arguments
Methods receive the definition (as a moddle reference) of the current activity and the processInstance (including its .payload) as arguments. Read more about creating plugins here (... link missing...).