Code Monkey home page Code Monkey logo

rules's Introduction

rules

Simple Rule Engine from Ant's blog. Able to process MVEL and Javascript rules in JVM, or run on Node.js.

Version 2.4.1:

  • Updated license to Apache 2.0

Version 2.3.1:

  • Removed constructors and methods which took Java 8 streams because it's not a good idea to pass streams around. Added constructors for using additional variables and static methods. See #9.

Version 2.2.2:

  • Updated dependency versions and copyright notices.

Version 2.2.1:

  • Fixed #4 - added checks to log level in order to improve performance.
  • Updated dependencies to latest versions

Version 2.2.0:

Version 2.1.0:

Also see the test classes, e.g. https://github.com/maxant/rules/tree/master/rules/src/test/java/ch/maxant/rules/blackbox, https://github.com/maxant/rules/tree/master/rules-java8/src/test/java/ch/maxant/rules/blackbox and https://github.com/maxant/rules/tree/master/rules-scala/src/test/scala/ch/maxant/rules/blackbox, or https://github.com/maxant/rules/tree/master/rules-js/test/rules-test.js.

Release Notes can be found here: https://github.com/maxant/rules/tree/master/rules/src/main/resources.

License

See LICENSE file.

Copyright 2011-2019 Ant Kutschera

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

  http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Building

# update versions in poms, to snapshot version, e.g. "2.4.1-SNAPSHOT"

# update dependency versions in poms

# update copyright years in:
#  - rules/src/main/resources/license.txt
#  - rules-java8/src/main/resources/license.txt
#  - rules-parent/license.txt
#  - rules-scala/src/main/resources/license.txt
#  - LICENSE

cd rules-parent

# ensure all is working
mvn clean package

# make changes

# ensure all is working
mvn clean package

# update release notes in "releaseNotes.txt" as well as in "README.md".

# build
mvn clean deploy

# when pop up requests password for gpg key, use the correct password!

# the above might require you to create a gpg key.
# see https://central.sonatype.org/pages/working-with-pgp-signatures.html
#   gpg --gen-key
#   gpg --list-keys
#
# now upload it:
#   gpg --keyserver keyserver.gpg.com  --send-keys ABCDEF
#   gpg --keyserver pool.sks-keyservers.net --send-keys ABCDEF
#   gpg --keyserver keys.gnupg.net --send-keys ABCDEF
#   gpg --keyserver keyserver.ubuntu.com --send-keys ABCDEF
#
# or maybe with hkp protocol?
#
#   gpg --keyserver hkp://keyserver.gpg.com  --send-keys ABCDEF
#   gpg --keyserver hkp://pool.sks-keyservers.net --send-keys ABCDEF
#   gpg --keyserver hkp://keys.gnupg.net --send-keys ABCDEF
#   gpg --keyserver hkp://keyserver.ubuntu.com --send-keys ABCDEF
#
# then go have a coffee. check
# http://keyserver.ubuntu.com/pks/lookup?search=ant%40maxant.co.uk&hash=on&op=vindex
# to see if the key is available.
#
# if it isn't try this:
#
#   gpg --armor --export [email protected]
#
# and import that manually at http://keyserver.ubuntu.com
#
# the above takes the letters (ID) which follow the "pub" key
# it is OK to create a brand new gpg key e.g. if your laptop explodes.
# see http://central.sonatype.org/pages/ossrh-guide.html
# need to ensure that servers section of maven settings.xml contains the following:
#    <server>
#      <id>ossrh</id>
#      <username>YOUR_USERNAME</username>
#      <password>YOUR_PASSWORD</password>
#    </server>
# note that the ID is the same as the one contained in the distributionManagement section of the parent pom

# after deployment, check the maven logs. you'll find something like this:
#    Uploading to sonatype: https://oss.sonatype.org/content/repositories/snapshots/ch/maxant/rules-java8/2.3.1-SNAPSHOT/maven-metadata.xml

# Go to https://oss.sonatype.org/content/repositories/snapshots/ch/maxant/ and double check it's all there

# Now if that all works, do the release:
# update versions in poms, to release version, e.g. "2.4.1"

# build
mvn clean deploy

# then you should either get a failed report, or logging like this:

  [INFO]  * Upload of locally staged artifacts finished.
  [INFO]  * Closing staging repository with ID "chmaxant-1012".

  Waiting for operation to complete...
  ........

  [INFO] Remote staged 1 repositories, finished with success.
  [INFO] Remote staging repositories are being released...

  Waiting for operation to complete...
  .........

  [INFO] Remote staging repositories released.
  [INFO] ------------------------------------------------------------------------
  [INFO] Reactor Summary:
  [INFO]
  [INFO] rules .............................................. SUCCESS [ 12.109 s]
  [INFO] rules .............................................. SUCCESS [ 24.242 s]
  [INFO] rules-java8 ........................................ SUCCESS [  4.704 s]
  [INFO] rules-scala ........................................ SUCCESS [01:55 min]
  [INFO] ------------------------------------------------------------------------
  [INFO] BUILD SUCCESS
  [INFO] ------------------------------------------------------------------------

# Your release will be ready here: https://oss.sonatype.org/#nexus-search;quick~maxant

# Finally go have a coffee and after a while, your release will also be ready in maven central:
#   https://mvnrepository.com/artifact/ch.maxant/rules

# don't forget to create a release in GitHub:

git commit -a -m'...'

git push origin master

git tag -a v2.4.1 -m'...'

git push origin v2.4.1

# go here and enter details, with title = v2.4.1
https://github.com/maxant/rules/releases/new

rules's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

rules's Issues

Help improve the logger performance

Could you add log level check first to improve performance?

String msg = r.getRule().getFullyQualifiedName() + "-{" + r.getRule().getExpression() + "}"; if(String.valueOf(o).equals("true")){ matchingRules.add(r.getRule()); log.info("matched: " + msg); }else{ log.info("unmatched: " + msg); }

No Response after 10th rule

Hi,

I'm running rules engine by java code as executable jar file. I'm running these rules engine by another java program to check against records in CSV file. After 10th row, I'm not getting response from this line - "Engine engine = new Engine(_rules, true);". Also no error thrown.

I can run the program successfully by Linux command directly. Also by eclipse in debug mode.

Pasted code below -

//Main another program
ProcessBuilder pb = new ProcessBuilder("java", "-jar", "myrules.jar", "jsonInput");
Process p = pb.start();

//Code in the JAR program
private int ruleEngine(List _rules, String input) {
int isPass = 0;
try {
Engine engine = new Engine(_rules, true);
isPass = engine.getMatchingRules(input).size();
} catch (Exception ex) {
isPass = 0;
System.out.println(ex.getMessage());
}
return isPass;
}

Please help me to fix the issue.

Thanks

Nitin C N

Building Java 8 example based on Java8EngineTest - scala error?

Trying to compile a project exemplifying Maxant rules.
please have a look and advise.

"The type scala.Function1 cannot be resolved. It is indirectly referenced from required .class files"

I also have this:

Archive for required library: 'C:/Users/zim/.m2/repository/ch/maxant/rules-scala/2.1.0/rules-scala-2.1.0.jar' in project 'MaxantExample' cannot be read or is not a valid ZIP file MaxantExample Build path Build Path Problem

I added a dependency in my POM to scala which came from your blog.

here is POM:

4.0.0
uo.MaxantExample
MaxantExample
0.0.1-SNAPSHOT


ch.maxant
rules
2.1.0



ch.maxant
rules-java8
2.2.1


ch.maxant
rules-scala
2.1.0


scalable to thousands of rules

Hi, this is more of a question. Do you have an idea is if this tool scales well with thousands of rules ( 3,000 ) that are going to be execute thousand of times (11,000) ?

Question regarding the rule engine

Hi

The project seems very interesting and I try to use it for my use case but I don't know if it's maching.
My use case is to receive a list of input and choose between _all these inputs_ the best matching to the rules.

So the outcome mechanism doesn't work for me. The action mechanism neither because all is related to find the rules matching the input.

My be I don't understand this enough could you help ?
Thanks

First it's cool ,second i have some questions.

hi,Ant
When I found this tool, I think it is so cool, now i have some questions。In particular, I hope you can help me。my use case is :

  1. i have many rules and user's action list in db or redis, The rules like this ,
    A:a person who register 3 days ago ,and Continuous login 10 days,and browse Electronic products 10 times。
    B:a person who browse Electronic products 10 times and browse Women's clothing products 5 times,
    now when a new user action(like david login 2016-05-20 08:00:00) come , i wana to know this action whether match rule A ,use david's action list history in redis. can "maxant/rules" do that ?
  2. if "maxant/rules" can do that now ,it is there anywway to transform the naturally lanaguage,to mvel expression.or is there anyway in web application to save the mvel expression to DB.

a person who register 3 days ago ,and Continuous login 10 days,and browse Electronic products 10 times=====>register >3 && login >10 && browse 01001
e.g:01001 means products Id in DB

Thank you so much!!! :

Not able to initialize Engine on Android.

Hi @maxant

java.lang.ExceptionInInitializerError at org.mvel2.MVEL.compileExpression(MVEL.java:810) at org.mvel2.MVEL.compileExpression(MVEL.java:820) at org.mvel2.MVEL.compileExpression(MVEL.java:723) at ch.maxant.rules.Engine$CompiledRule.<init>(Engine.java:385) at ch.maxant.rules.Engine$CompiledRule.<init>(Engine.java:380) at ch.maxant.rules.Engine.init(Engine.java:204) at ch.maxant.rules.Engine.<init>(Engine.java:114)

Help improve logging performance. Debug logging

`if (log.isLoggable(Level.INFO)) {

  log.info("matched: " + msg);

}

if (log.isLoggable(Level.INFO)) {

  log.info("unmatched: " + msg);

}`

The above log statements could be changed to DEBUG. In my system where there are 100+ rules run against 10,000+ transactions per minute. This log statement quickly takes over all the logs. If you change this log to DEBUG we would be able to keep helpful information like what rules are loaded but the information for which rules are matched is more of a DEBUG information for when we encountered an issue

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.