Skip to content

Easy Rules with Spring Boot example, save rules via REST API, save composite rules via REST API, process entity through rules via REST API

Notifications You must be signed in to change notification settings

tsarenkotxt/rule-engine-example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Easy Rules with Spring Boot

Simple example with Rule Engine (easy-rules):

  • save rules via REST API
    • save composite rules via REST API
  • process entity through rules via REST API

Requirements

Java 11

Get started

Run Spring Boot application

./gradlew bootRun

Save simple rule

URL - http://localhost:8080/rules
HTTP Method - POST

{
  "name": "person rule 1",
  "description": "simple person rule for save",
  "priority": 1,
  "condition": "person.item.name == \"some item\"",
  "action": "savePerson"
}

Save composite rule

URL - http://localhost:8080/rules/composite
HTTP Method - POST

{
  "name": "composite person rule 1",
  "rules": [
    {
      "name": "person rule 2",
      "description": "simple person rule for send to vendor one",
      "priority": 1,
      "condition": "person.age > 10",
      "action": "sendPersonToVendorOne"
    },
    {
      "name": "person rule 3",
      "description": "simple person rule for send to vendor two",
      "priority": 1,
      "condition": "person.item.count == 1",
      "action": "sendPersonToVendorTwo"
    }
  ]
}

Process Person through rules

URL - http://localhost:8080/persons
HTTP Method - POST

{
  "name": "some name",
  "age": 18,
  "item": {
    "name": "some item",
    "count": 1
  }
}

Response:

{
  "person rule 1": true,
  "composite person rule 1": true
}

Get available actions

URL - http://localhost:8080/persons
HTTP Method - GET

Response:

[
  "savePerson",
  "sendPersonToVendorOne",
  "sendPersonToVendorTwo",
  "sendPersonToVendorThree"
]

Swagger UI

URL - http://localhost:8080/swagger-ui.html#/

About

Easy Rules with Spring Boot example, save rules via REST API, save composite rules via REST API, process entity through rules via REST API

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages