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
      • Dependency
      • Configuration
      • Configuration instructions
      • Auto refresh
    • 📋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
    • 🍥Simple monitor
    • 🧉DTD in Xml
  • ⛱Test cases and demo

    • 🪁Test cases
    • 🪀Demo
  • 🪂Performance
  • v2.9.X文档
  • 🗂Rules file
铂赛东
2022-10-11
Contents

📘SQL database source

Starting from v2.9.0, LiteFlow supports the configuration source of standard structured databases, as long as your database is compatible with standard SQL syntax, it can be supported.

# Dependency

If you use a database as a rule configuration source, you need to add the following additional plugin dependencies:

<dependency>
    <groupId>com.yomahub</groupId>
    <artifactId>liteflow-rule-sql</artifactId>
    <version>2.9.3</version>
</dependency>

# Configuration

You do not need to configure the liteflow.ruleSource.

    liteflow:
      rule-source-ext-data-map:
        url: jdbc:mysql://localhost:3306/poseidon
        driverClassName: com.mysql.cj.jdbc.Driver
        username: root
        password: 123456
        applicationName: demo
        #以下是chain表的配置,这个一定得有
        chainTableName: chain
        chainApplicationNameField: application_name
        chainNameField: chain_name
        elDataField: el_data
        #以下是script表的配置,如果你没使用到脚本,下面可以不配置
        scriptTableName: script
        scriptApplicationNameField: application_name
        scriptIdField: script_id
        scriptNameField: script_name
        scriptDataField: script_data
        scriptTypeField: script_type
    
    liteflow.rule-source-ext-data={\
      "url":"jdbc:mysql://localhost:3306/poseidon",\
      "driverClassName":"com.mysql.cj.jdbc.Driver",\
      "username":"root",\
      "password":"123456",\
      "applicationName": "demo",\
      "chainTableName": "chain",\
      "chainApplicationNameField": "application_name",\
      "chainNameField": "chain_name",\
      "elDataField": "el_data",\
      "scriptTableName": "script",\
      "scriptApplicationNameField": "application_name",\
      "scriptIdField": "script_id",\
      "scriptNameField": "script_name",\
      "scriptDataField": "script_data",\
      "scriptTypeField": "script_type"
      }
    
    // Make sure to add code blocks to your code group

    # Configuration instructions

    LiteFlow does not restrict your table name and table structure, you only need to configure the table name and related field names in the parameters.

    The configuration items are described as follows:

    Configuration item Description
    url Jdbc connection url
    driverClassName Driver class name
    username Database username
    password Database password
    applicationName Your application name
    chainTableName The table name of the rule table
    chainApplicationNameField Application name field name in rule table
    chainNameField The field name of the rule name
    elDataField Field of EL expression (only EL is stored)
    scriptTableName The table name of your script table
    scriptApplicationNameField Application name field name in the script table
    scriptIdField The field name of the Id of the script component
    scriptNameField The field name of the script component name
    scriptDataField Field name of script data
    scriptTypeField The field name of the script type (type refer to Define Script Component)

    In the database, you need at least one table to store the rules.

    If you use scripts, you need a second table to store the scripts.

    In a rule table, a row of data is a rule. In a script table, a row of data is a script component.


    example:

    rule table: liteflow_chain

    id application_name chain_name chain_desc el_data create_time
    1 demo chain1 test chain 1 THEN(a, b, c, s1,s2); 2022-09-19 19:31:00

    script table: liteflow_script

    id application_name script_id script_name script_data script_type create_time
    1 demo s1 script s1 import cn.hutool.core.date.DateUtil
    def date = DateUtil.parse("2022-10-17 13:31:43")
    println(date) defaultContext.setData("demoDate", date)
    class Student {
    int studentID
    String studentName
    }
    Student student = new Student() student.studentID = 100301 student.studentName = "张三" defaultContext.setData("student",student) def a=3
    def b=2
    defaultContext.setData("s1",a*b)
    script 2022-09-19 19:31:00
    2 demo s2 script s2 defaultContext.setData("s2","hello") script 2022-09-19 19:31:00

    # Auto refresh

    Since the structured database does not provide a monitoring mechanism, when your rules change in the database, LiteFlow cannot perceive the change. Rules are not refreshed automatically.

    You need to manually call the relevant API provided by LiteFlow to complete the rule refresh. In practical applications, you can make this refresh a button or an http link on the page to operate.

    For details on how to call the API to refresh the rules, please refer to Smooth hot refresh.

    Help us improve this document (opens new window)
    last update: 2022/11/30, 22:42:09
    📗Zookeeper source
    📋Nacos source

    ← 📗Zookeeper source 📋Nacos source→

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