3

我是 Drools 的新手,并试图了解这一切......

我在 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

并从 Postman 我使用 REST API 调用以下内容:

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"
}]
}

从服务器返回的响应是成功的:

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

但是我在 server.log 中没有看到我的 println 消息...所以我怀疑该规则是否按预期触发?任何建议我将不胜感激。

4

1 回答 1

4

POST 正文的 JSON 中有错字。对象是

demo.dummyapp.SMS

并不是

demo.dummpyapp.SMS

容器调用成功,但没有匹配的规则。因此valueJSON 响应中的关键是0.

尝试发出这个 POST 请求:

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"
}]
}
于 2017-11-12T13:50:23.250 回答