3

I'm new to Drools and trying to get my head round it all...

I have a rule which I've created in Workbench 6.3.0.Final:

package demo.dummyapp;

import java.lang.Boolean;

rule "RuleThree"
    dialect "mvel"
    when
        SMS(sendMessage == true )
    then
        System.out.println( "This message is being sent" );
end

and from Postman I call using REST API the following:

POST: http://myserver/kie-server-6.3.0.Final-ee7/services/rest/server/containers/instances/dummyapp

{
"lookup": "ksession1",
"commands": [{
"insert": {
"return-object": true,
"object": {
"demo.dummpyapp.SMS": {
"sendMessage": true
   }
  }
 }
}, {
"fire-all-rules": "RuleThree"
}]
}

The response back from the server is successful:

{
  "type": "SUCCESS",
  "msg": "Container dummyapp successfully called.",
  "result": "{\n  \"results\" : [ {\n    \"key\" : \"RuleThree\",\n    \"value\" : 0\n  } ],\n  \"facts\" : [ ]\n}"
}

however I don't see my println message in the server.log... so I doubt the rule is firing as expected? Any advice I'd be grateful.

laune
  • 31,114
  • 3
  • 29
  • 42
NewbieGrails
  • 93
  • 2
  • 11
  • Are you sure that a println ends up in the server.log? - Or: throw an exception, which should show up. – laune Jan 04 '16 at 13:51
  • nothing is showing up in the server log at all. I've stripped but rule back to the basics. I either want to see an error or the println but nothing? – NewbieGrails Jan 04 '16 at 14:29
  • sorry misunderstood your question... No exception is thrown is sendMessage value is true or false? I don't see a way I can validate that my rule file is working correctly? – NewbieGrails Jan 04 '16 at 14:50
  • I don't see anything in the syslog either nor console.log – NewbieGrails Jan 04 '16 at 15:04
  • What I meant is to add a `throw IllegalStateException` to the right hand side code of rule `"RuleThree"`. That this doesn't change anything in the logs, and that the return value of fireAllRules is zero (no rules have been fired) indicates that you don't execute a container containing this rule. – laune Jan 04 '16 at 15:56
  • so no exception is thrown so the rule doesn't even get executed which baffles me even more! – NewbieGrails Jan 05 '16 at 13:00
  • I can't tell from what you have in your question, but there must be something fundamentally wrong in your setup where you define what and how to execute out of the Workbench development environment. I'm not familiar with the latest distribution but there ought to be some example for your use case: did you manage to execute that? – laune Jan 06 '16 at 02:50
  • Did you get any solution for this? – Vishal Vijay Nov 10 '17 at 15:29

1 Answers1

4

There is a typo in the JSON of the POST body. The object is

demo.dummyapp.SMS

and not

demo.dummpyapp.SMS

The container was called successfully but no rule matched. Thus the value key in JSON response was 0.

Try making this POST request:

POST: http://myserver/kie-server-6.3.0.Final-ee7/services/rest/server/containers/instances/dummyapp

{
"lookup": "ksession1",
"commands": [{
"insert": {
"return-object": true,
"object": {
"demo.dummyapp.SMS": {
"sendMessage": true
   }
  }
 }
}, {
"fire-all-rules": "RuleThree"
}]
}
Shivansh Gaur
  • 918
  • 9
  • 11