bpmnServer / bpmn-server

BPMN 2.0 server for Node.js , providing modeling, execution, persistence and monitoring for Workflow. along with sample UI. Intended to be developers workbench for BPMN 2.0
MIT License
186 stars 48 forks source link

What is findEvents #217

Closed linonetwo closed 4 months ago

linonetwo commented 4 months ago
export class TiddlyWikiModelsDatastore implements IModelsDatastore {
  async findEvents(query: { 'events.subType': 'Timer' }): Promise<any[]> {
    return [];
  }

What does its input "Timer" mean? Also what should be returned?

linonetwo commented 4 months ago
截屏2024-07-23 00 10 41

Difficult to tell from the code, and its comment is difficult to understand to me.

/**
    returns Model Events (like timers) for authorized to the user and based on specifid query
*/

     findEvents(query:any, user?: ISecureUser);
ralphhanna commented 4 months ago

bpmn models can have events that need to be processed by the engine without engine.start So if a model has a start timer event, the engine need to monitor that and start the model.

linonetwo commented 4 months ago

Thanks, do you mean this?

截屏2024-07-24 13 11 24

Currently if reading of BPMN file is triggered by engine.start

await api.engine.start('log-console.bpmn', { key: 'value' }, SystemUser);
// only after this, the ModelsDatastore.getSource is called to get bpmn file

I'm confused about who add the timer event, and what's timer event's interface. I will add some TS type after I make it clear.

ralphhanna commented 4 months ago

Actually, there are few scenarios:

image

  1. Timer Start Event
  2. Message Start Event
  3. Signal Start Event

On saving the model, data is parsed and those events are saved into the DB.

image

For Timer Start Events, on bpmn-server start ,findEvents is called for timers and then processed.

For Message and Signals, when a message is called, findEvents is called for the message/signal

linonetwo commented 4 months ago

On saving the model

This is another question, I haven't seem this gets called. Do I need to call something to trigger this?

I find many method is not called when I only use api.engine.start

https://github.com/tiddly-gittly/workflow/blob/1e086573e1ba416bb762c0e1a7807ede44570f43/src/workflow-engine/engine/data/twModelDataStore.ts#L16-L62

linonetwo commented 4 months ago

when a message is called

Am I understand correctly? When you api.engine.start a bpmn file, it register message/signal listener on computer memory, and when I trigger the "saving the model", it save to DB. And I can stop the bpmn file safely.

Later, when computer restart, and new BPMNServer(config, config.logger), it get the infomation back, and auto load the related BPMN file based on processId.

ralphhanna commented 4 months ago

Not exactly Model save must happen first When message is fired it finds the corresponding responder; either a running workflow or a model start event; it doesn’t wait Sent from my iPhoneOn Jul 24, 2024, at 1:57 AM, lin onetwo @.***> wrote:

when a message is called

Am I understand correctly? When you api.engine.start a bpmn file, it register message/signal listener on computer memory, and when I trigger the "saving the model", it save to DB. And I can stop the bpmn file. Later, when computer restart, and new BPMNServer(config, config.logger), it get the infomation back, and auto load the related BPMN file based on processId.

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you commented.Message ID: @.***>

linonetwo commented 4 months ago

I will test this and write doc.