Search code examples
javajbossdrools

Can we use multiple when then condition in a single rule in Drools.?


I am writing a .drl file to implement Drools rules. As per business requirements I need to check 3 conditions for a single rule. So my question is, is it possible to have multiple when in the same rule.

I did search for many hours, but I didn't get any useful info. Can someone please guide me how to write multiple when in the single rule in drools.

Ie is it possible to do like this?

rule "Test rule 1"
    when 
        condition1
    then
        <execute code>
    when
        condition2
    then
        <execute code>
end

Solution

  • No, 80% sure you can not. You caught me with a opened .drl and did a try, says 'mismatched input', but fails on the inmediate token after the second then. Hence the 80% (to say some number). Cheerfully the compiler passed all along the second when without fail.

    Try and post.