"Drools-open source Business rules engine" example of getting started (including source code)

Source: Internet
Author: User


The instance is transferred from: http://blog.csdn.net/quzishen/article/details/6163012

Easy to understand application Example 1:

Now we are simulating an application scenario: a site that is associated with a business-generated point issuance operation. such as Alipay credit card repayment bonus points.

Issuance points may be accompanied by different operating strategies and seasonal adjustments, the number and rules of issuance are completely different, if the use of hard-coded to accompany the business adjustment and modification, code modification, management, optimization, testing, on-line will be a very troublesome thing, so, the release rules are extracted, to drools management, Can solve this problem to a great extent.

(Note that not all rules-related content is recommended to use Drools, which is to consider how long the system will run, change the frequency of rules and other conditions, if your system will only run a week online, there is no need to choose Drools to increase your development costs, Java hard-coded way will be preferred)

We define the issuance rules:

points for the distribution of reference factors are: the number of transactions, the number of transactions, credit card repayment times, birthday special offers and so on.

To define a rule:

Birthday, then add 10 points, and the current month to double the number of transactions before calculating points

2011-01-08-2011-08-08 Monthly credit card repayment more than 3 times, each full 3 gift 30 points

Monthly purchase of more than 100 of the total amount, every 100 yuan free 10 points

Purchase more than 5 times in the month, give 50 points every five times

In particular, if all the requirements are met, an additional bonus of 100 points

Return, deduction of 10 points

Return amount greater than or equal to 100, deduction of 100 points

According to these rules, we let drools automatically calculate for us the number of points issued for a particular user.

Source: Https://github.com/XBWer/DroolsDemo

Another example--QQ level acceleration

Accelerates according to a series of acceleration rules.







If you had any questions about this article, welcome to leave a message on the message board.


Brad (Bowen Xu)
E-mail:max_xbw@163.com

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.