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
      • Pre Component
      • Finally component
      • About sequence
      • Scope
    • 🥠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
    • 🍥Simple monitor
    • 🧉DTD in Xml
  • ⛱Test cases and demo

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

🍒Pre & Finally components

LiteFlow supports pre-component and finally-component features.

Used to execute certain components before or after the chain.

The front and finally components are both serial nodes and do not support asynchronous.

# Pre Component

To execute certain nodes before a chain starts, use the PRE keyword (must be capitalized) in EL rules:

<chain name="chain1">
    THEN(
        PRE(p1, p2), 
        a, b, c, 
        WHEN(d, e)
    );
</chain>

# Finally component

Execute some nodes after a chain ends. It should be noted that the finally component is not affected by Exception. Even if the node fails, the finally component will still be executed. Use the FINALLY keyword (must be capitalized) in EL rules:

<chain name="chain1">
    THEN(
        a, b, c, 
        FINALLY(f1, f2)
    );
</chain>

# About sequence

Does the pre component have to be written in front? Does the finally component have to be written at the end?

No, PRE and FINALLY can be written anywhere in the first layer.

for example:

<chain name="chain1">
    THEN(
        PRE(a), c, d, FINALLY(f1, f2)
    );
</chain>

The following expression is equivalent to the above, even if it is not placed in the corresponding position, it still has the same effect.

<chain name="chain1">
    THEN(
        FINALLY(f1, f2), c, PRE(a), d
    );
</chain>

What is the first layer, please see the following example:

<chain name="chain1">
    THEN(
        a, THEN(PRE(b,c), d)
    );
</chain>

In the above example, PRE will not be executed. Because it's on the second layer. Valid only for PRE and FINALLY at the first layer.

# Scope

It is worth mentioning that the scope of PRE and FINALLY is the current Chain.

This also means that if you use PRE and FINALLY in a sub chain, it will only work for the sub chain.

Take a look at the following example:

<chain name="chain1">
    THEN(PRE(p1, p2), chain2, FINALLY(f1));
</chain>

<chain name="chain2">
    THEN(PRE(p3), a, b, FINALLY(f2));
</chain>

If executed correctly, the resulting steps should look like this:

p1=>p2=>p3=>a=>b=>f2=>f1

Help us improve this document (opens new window)
last update: 2022/10/13, 00:02:27
🎯How to build
🥠Substitute component

← 🎯How to build 🥠Substitute component→

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