How to pass input parameters to a Jboss BRMS Rule from Rest Client

时间:2016-09-01 06:16:59

标签: java jboss redhat rule-engine kie-server

I have created a Rule using a decision table in Jboss BRMS and deployed as a REST service using the kie-server. But can't find how to pass parameters to the service.

When I create a Test Scenario and execute the Rule service, It runs fine.

kie-container shows me the End point as
http://host:port/kie-server/services/rest/server/containers/container1

But I can't find how to pass parameters to the service using a Rest Client (Advanced Rest Client).

I send this Parameters with the Request and it gives me the following response.

REQUEST

{
 "commands":[
   {
      "insert":{
         "out-identifier":"Customer",
         "return-object":"true",
         "object": {
           "example.si.Customer":{
             "time":3,
             "age":70,
             "gender":"MALE"
           }
         }
       }
   },
   {
      "fire-all-rules":""
   }
 ]
  }

  >HEADERS
    X-KIE-ContentType: JSON
    Accept: application/json
    Content-Type: application/json
    authorization: Basic a2llc2VydmVyOmtpZXNlcnZlcjEh


>RESPONSE
     {
      "type": "SUCCESS"
       "msg": "Container sinterest5 successfully called."
       "result": "{ "results" : [ { "key" : "", "value" : 0 }, { "key"   : "Customer", "value" : {"example.si.Customer":{ "time" : 3, "age" : 70,   "interest" : null, "gender" : "MALE", "rate" : null, "amount" : null }} } ], "facts" : [ { "key" : "Customer", "value" :     {"org.drools.core.common.DefaultFactHandle":{ "external-form" : "0:5:695977235:695977235:5:DEFAULT:NON_TRAIT:example.si.Customer" }} } ]     }"
       }



 And my Rule is.. 


package Deciding_Rates;
   //generated from Decision Table
   import example.si.Customer;
  function void interest(int time, int rate, int amount)
  {System.out.println ( (time * rate * amount )/100        );System.out.println(System.currentTimeMillis());}
        lock-on-active true
       // rule values at C15, header at C10
         rule "DecidingRate_15"
        ruleflow-group "Rate"
        when
         $customer : Customer(Time< 5, Age>=65, Gender == "MALE")
         then
        modify($customer){setRate(10)};
       System.out.println("Time < 5, Senior, Male");
       interest($customer.getTime(), $customer.getRate(), 100);
  end

     // rule values at C16, header at C10
      rule "DecidingRate_16"
      ruleflow-group "Rate"
      when
          $customer : Customer(Time< 5, Age>=65, Gender == "FEMALE")
      then
         modify($customer){setRate(11)};
         System.out.println("Time < 5, Senior, Female");
         interest($customer.getTime(), $customer.getRate(), 100);
       end

       // rule values at C17, header at C10
        rule "DecidingRate_17"
        ruleflow-group "Rate"
        when
         $customer : Customer(Time< 5, Age<65, Gender == "MALE")
        then
         modify($customer){setRate(8)};
         System.out.println("Time < 5, young, Male");
          interest($customer.getTime(), $customer.getRate(), 100);
          end

Am I doing anything wrong Here? Sysouts are not visible in server logs. I am not sure is my rules are getting fired or not.