Go-activiti process engine node event callback

Go language process engine go-activiti

Project portal go-activiti

Refer to Activiti to achieve some functions. The project is still being improved, activiti fans are welcome to join.

Node event callback

There are two cases here, whether the task node is set to approve users and user groups

Situation 1: There is no approver

After this kind of node arrives, it will try to call back the business. If the business has no task processing, skip this node directly (the historical data will be streamed)
Insert picture description here

Situation 2: There is an approver

Here you need to set up the listener event (TaskListeners) when drawing the flowchart,
Insert picture description here
here just set the type of the listener event.

Register business callback class

Need to implement IActiviti, registration constructor, refer to iActivitiDemo.go file.
Note that the registration name here is the process name, which is case sensitive. Process-related data can be obtained from ExecutionEntity.

func init() {
    
    
	RegisterConstructor("userAuto", NewTestIActiviti)
}

func NewTestIActiviti(entity ExecutionEntity) IActiviti {
    
    
	return &TestIActiviti{
    
    
		Entity: entity,
	}
}
func (test *TestIActiviti) User001() (code interface{
    
    }, err error) {
    
    
	variable := test.Entity.GetVariable()
	fmt.Println(variable)
	return common.ACTIVITI_HANDLER_CODE, nil
}

func (test *TestIActiviti) User002() (code interface{
    
    }, err error) {
    
    
	return common.ACTIVITI_HANDLER_CODE, nil
}

User001 and User002 here correspond to the node name, which is case sensitive, that is, the monitoring event is set, and the method here will be executed when the node arrives. The return value is common.ACTIVITI_HANDLER_CODE, which is successful by default. If an exception is thrown, the process will roll back.
Insert picture description here

Guess you like

Origin blog.csdn.net/qq_34758074/article/details/113094682