0

I am new to drools, and have a scenario, where I need to invoke a mule flow from drools. I have defined mule flows as below and want to invoke one of the flow based on some condition.

<flow name="Flow1">
    <http:listener config-ref="flw1" path="/check1" doc:name="Evaluation Srv" />

    <http:request config-ref="Proxy" path="/check1" method="GET" doc:name="basic validation" />
</flow>

<flow name="Flow2">
    <http:listener config-ref="flw1" path="/check2" doc:name="Notification" />

    <http:request config-ref="Proxy" path="/check2" method="GET" doc:name="Personal validation">
    </http:request>
</flow>

I have a sample drools file, as below

#default dialect for the semantic code will be MVEL
global org.mule.module.bpm.MessageService mule;

import com.mule.sbus.drools.RequestUrl

dialect "mvel"

declare RequestUrl
    @role(event)
end

rule "/check1"
    lock-on-active
when
    $url:RequestUrl(url=="check1")
then
    #invoke flow1
end

rule "/check2"
    lock-on-active
when
    $url:RequestUrl(url=="check2")
then
    #invoke flow 2
end

Please let me know how to invoke the flow from drools

Saurabh Jhunjhunwala
  • 2,832
  • 3
  • 29
  • 57

1 Answers1

1

If you know how to invoke it from Java, then you know how to invoke it from Drools. The Right Hand Side (then part) of a rule is basically Java code. One thing to have in mind though, is that the execution of the rules in Drools is single-threaded. No other rules will be executed/evaluated while you are invoking mule inside a rule.

An option would be to use an asynchronous executor.

Hope it helps,

Esteban Aliverti
  • 6,259
  • 2
  • 19
  • 31