Library / Documentation

Drools documentation

Documentation for a widely used open-source business rules engine.

By Drools community · Drools (KIE) · Added 2026-10-12

Open the docs

All content belongs to Drools community / Drools (KIE). We only link to it and give credit. Report a problem

Learn this doc

About 30 min left. Your work is saved as you go.

What you want from these docs

Drools (KIE) documents a tool you may use. Decide what you want to do with it, then read only what answers that.

Ideas you will meet

Event Driven Architecture
Loosely coupled services reacting to events.

What we already know about this

Our own lessons on these ideas. Read them here before you start, so it makes sense.

  • Storage, Queues and Real-time · 11 minA rule engine and trigger frameworkMatch product events against versioned rules and run actions safely: rule shape, evaluation, idempotent actions, rate limits, testing and audit.Read here

    What it is

    A rule engine (or trigger framework) lets you say "when this happens and if these conditions hold, do that", without writing a new code path each time. Examples: send a welcome message when a user signs up, flag an order when the amount is unusual, award a badge after five purchases.

    Product and operations teams want to change these often, so the rules should be data that a service evaluates, not code that must be redeployed.

    Figure SDA-SQR-04-1 · From event to action · © forcsguy.com

    What a rule contains

    • Identity and version: id, version, owner, enabled. Never edit in place; publish a new version so you can audit and roll back.
    • Trigger: an event type, or a schedule for time-based rules.
    • Condition: a structured tree such as all of [ plan = free, country in (IN, US), purchases >= 5 ], or a restricted expression language. Avoid arbitrary code.
    • Action: a named action with parameters (send_email(template_id), add_badge(name)).
    • Controls: cooldown, per-user and global limits, start and end dates.

    Evaluating efficiently

    • Index rules by event type so an event only looks at its few candidate rules, not all rules.
    • Fetch extra user data (attributes, counters) lazily and cache it for the duration of the event, as lookups usually cost more than the comparisons.
    • For time-based conditions ("14 days without login") run a scheduled scan or use delayed events, rather than polling every user.
    • Evaluate in workers that are partitioned by user, so state like cooldowns and counters for one user is handled in order.

    Safe, idempotent actions

    Events can be delivered more than once and workers retry. Guard every action with an idempotency key, for example rule:version:user:window, stored in a unique-key table or key-value store before (or together with) performing the action.

    Figure SDA-SQR-04-2 · Idempotent action execution · © forcsguy.com

    Operating a rule engine

    • Validation at publish time: reject unknown fields, huge conditions and loops.
    • Dry run and replay: run a new rule against recent historical events and report how many it would fire, before enabling it.
    • Kill switch per rule and globally, since a bad rule can email a million users.
    • Limits: maximum rule size, evaluation time and actions per event.
    • Audit: who changed which version and when; for each event, which rules fired or were skipped and why.
    • Know the cost: a large pile of rules becomes software nobody understands. Fowler's advice is to prefer plain code for logic that rarely changes, and use rules for what truly varies.

    Real-world reading

    Open this lesson with its quiz and exercise

Go deeper on this

A path through videos, articles, other case studies and code on the same ideas as Drools documentation.

  1. Warm upGet the vocabulary first.

  2. WatchHow others solve the same problem, on video.

    Videos belong to their creators and play from YouTube. More on YouTube (opens in a new tab)

  3. ReadEngineers explain it in their own words.

  4. See it in another companyThe same ideas, a different system.

  5. Read the codeSee how it looks when it is real.

Keep learning

Loading community…