LiteFlow LiteFlow
💒Home
📚Documents
💖Donation
🚀Plugin
  • About LiteFlow
  • Update Record
Community
Users
Gitee (opens new window)
Github (opens new window)
  • 简体中文 (opens new window)
  • English (opens new window)
💒Home
📚Documents
💖Donation
🚀Plugin
  • About LiteFlow
  • Update Record
Community
Users
Gitee (opens new window)
Github (opens new window)
  • 简体中文 (opens new window)
  • English (opens new window)
  • 🍤Introduction
  • 🍓Features
  • 🍟Quick Start(Hello world)

    • 🍄Notice
    • 🌿Springboot environment

      • 🧬Dependency
      • ⚙️Config
      • 🛫Execute
    • 🌱Spring environment

      • 🧬Dependency
      • ⚙️Config
      • 🛫Execute
    • 🌵Other environment

      • 🍄Notice
      • 🧬Dependency
      • ⚙️Config
      • 🛫Execute
  • 🍢Configuration item

    • 🍄Notice
    • 🌿Springboot environment
    • 🌱Spring environment
    • 🌵Other environment
  • 🗂Rules file

    • 📔Rules file format
    • 📕Local rule file
    • 📗Zookeeper source
    • 📘SQL database source
    • 📋Nacos source
    • 🗄Etcd source
    • 📙Custom source
  • 🔗General components

    • 📎Common component
    • ✂️Switch component
    • 📌If component
    • 🧬For component
    • ⛓While component
    • 🧿Break component
  • 🧩How to write EL rules

    • 🍄Notice
    • 🌴Serial mode
    • 🎋Parallel mode
    • 🌾Switch mode
    • 🌵If mode
    • 🌳Loop mode
    • 🍁Use sub chain
    • 🍂Use sub variables
    • 💐Complex example
    • 🌻About semicolons
    • 🌰About comments
    • 🐚Component Name Package
  • 🌮Data context

    • 🍄Notice
    • 🌯Definition and use
    • 🪶Pass initialized context
  • 🛩Flow executor

    • 🍄Notice
    • 🎡Executor method
    • 🎢Chain input parameter
    • 🎈LiteflowResponse object
  • 🍋Script component

    • 🍫Choose a script language
    • 🍕Define script component
    • 🌯Define file script
    • 🍣Interact with java
    • 🍘Dynamic refresh script
  • 🍇Declarative component

    • 🥭What is a declarative component
    • 🧅Class level declaration
    • 🥥Method level declaration
  • 🎲Dynamic rules

    • 🍄Notice
    • 🎯How to build
  • 🎨Advanced features

    • 🍒Pre & Finally components
    • 🥠Substitute component
    • 🍉Component Parameters
    • 🍑Component alias
    • 🍍Component tag
    • 🥝Component event
    • 🥑Implicit chain
    • 🍕Private delivery
    • 🍣Component retry
    • 🍖Smooth hot refresh
    • 🍪Component aspect
    • 🍡Step information
    • 🧊Exceptions
    • 🧇Printing details
    • 🧁Custom request id
    • 🌭Multiple type rules
    • 🥗Asynchronous thread pool
    • 🍿Custom component executor
      • Global component executor
      • Configure executor for one components
      • Priority
      • The impact of custom executors on retry functions
    • 🍥Simple monitor
    • 🧉DTD in Xml
  • ⛱Test cases and demo

    • 🪁Test cases
    • 🪀Demo
  • 🪂Performance
  • v2.9.X文档
  • 🎨Advanced features
铂赛东
2022-07-03
Contents

🍿Custom component executor

LiteFlow allows users to define custom component executors, which can be used to add custom code and rewrite retry policies when executing components. Of course other ways to accomplish the same purpose are possible, such as the component aspect feature.

If you are not very clear about what this feature does, it is recommended to use the default way. (Which really means no need to read this section)

# Global component executor

For custom component executors, you can override them globally. The default component executor is:com.yomahub.liteflow.flow.executor.DefaultNodeExecutor

You can replace the global default component executor by:

liteflow.node-executor-class=com.yomahub.liteflow.test.nodeExecutor.CustomerDefaultNodeExecutor

Custom component executors need to inheritcom.yomahub.liteflow.entity.executor.NodeExecutor。

public class CustomerDefaultNodeExecutor extends NodeExecutor {
    @Override
    public void execute(NodeComponent instance) throws Exception {
        LOG.info("use customerDefaultNodeExecutor to execute");
        super.execute(instance);
      
      	//You can add your own code here, the above code can be removed.
      	//But make sure to at least call instance.execute(), otherwise the component will not be executed correctly.
    }
}

# Configure executor for one components

single components also support configuring custom executor.

You need to implement the getNodeExecutorClass method when defining the component:

@LiteflowComponent("d")
public class DCmp extends NodeComponent {

    @Override
    public void process() {
        System.out.println("DCmp executed!");
    }

    @Override
    public Class<? extends NodeExecutor> getNodeExecutorClass() {
        return CustomerNodeExecutorAndCustomRetry.class;
    }
}

# Priority

If both global and single component are configured with custom executors, the executor configured on the single component will take precedence.

# The impact of custom executors on retry functions

Because the retry logic is implemented in the default executor. So if you configure a custom executor, the retry function needs to be implemented by yourself. And the global retry parameter configuration and the @LiteflowRetry function tag will be invalid.

Of course, if you implement your own custom executor, you can still get the retry parameters and write your own special retry logic. All this needs to be done by yourself. Pay attention to this.

Help us improve this document (opens new window)
last update: 2022/10/28, 15:41:57
🥗Asynchronous thread pool
🍥Simple monitor

← 🥗Asynchronous thread pool 🍥Simple monitor→

Theme by Vdoing | Copyright © 2020-2022 铂赛东 | MIT License
  • 跟随系统
  • 浅色模式
  • 深色模式
  • 阅读模式