KIE-Server 6.4.0 Rest API Documentation

3,230 views
Skip to first unread message

Grant Ferguson

unread,
Oct 12, 2016, 2:43:22 PM10/12/16
to Drools Usage, Grant B. Ferguson
Hi All,

I've consulted the documentation here: https://docs.jboss.org/drools/release/6.4.0.Final/drools-docs/html_single/#d0e24633 about the KIE Server REST api and was wondering if someone could help me clarify a gap that either exists in my understanding or elsewhere. In that document (link posted above), in section "22.6.7. [POST]/containers/instances/{id}", there is a short example that mentions to send <fire-all-rules/> as a command over XML to execute rules. Beneath that, there are a list of support commands, and after which, a mention that the commands can be found in the org.drools.core.command.runtime package.

Since there is no other documentation at this page for either JSON or XML formatting of REST requests and how to execute deployed rules, I started using trial-and-error while executing REST calls to my local KIE server to realize that I needed a basic auth header, another header named X-KIE-ContentType, and what the format of the JSON or XML requests should look like. 

I could not find any other JBoss/RedHat/KIE/other documentation that had a FULL REST api documentation for the KIE Server and executing rules. 

For example, is there somewhere that explains that if I want to execute rules using the REST API with JSON, that I need to have a JSON array of comands, and the documentation for each type of command and its format in the JSON request? or I am just supposed to know how they map from Java? All I have found is documentation for Java api's. (https://docs.jboss.org/jbpm/v6.3/javadocs/org/kie/api/command/KieCommands.html

Thanks in advance for any help, I'm just trying to learn!

Grant

Ged Byrne

unread,
Oct 12, 2016, 5:33:08 PM10/12/16
to Drools Usage, Grant.F...@fmr.com

Stathis Rouvas

unread,
Oct 13, 2016, 5:10:29 AM10/13/16
to Drools Usage, Grant.F...@fmr.com
Hi,

here are my notes for working with KIE server. Not terribly organised I'm afraid, but I hope they can be of some use:


Bits and pieces:


1. Find out about available repositories:
  curl -H 'Accept: application/json' -H 'Content-Type: application/json' -X GET -u 'bpmsAdmin:p4ssw0rd' 'http://localhost:8080/business-central/rest/repositories' | json_xs

  [
        {
        "name": "repository1",
        "description": null,
        "userName": null,
        "password": null,
        "requestType": null,
        "gitURL": "git://repository1"
     },
        {
        "name": "hw2Repo",
        "description": null,
        "userName": null,
        "password": null,
        "requestType": null,
        "gitURL": "git://hw2Repo"
     },
        {
        "name": "hw1Over",
        "description": null,
        "userName": null,
        "password": null,
        "requestType": null,
        "gitURL": "git://hw1Over"
     },
        {
        "name": "helloworldrepo",
        "description": null,
        "userName": null,
        "password": null,
        "requestType": null,
        "gitURL": "git://helloworldrepo"
     }
  ]


2. Explore Organizational Units (to check repository ownership)
  curl -H 'Accept: application/json' -H 'Content-Type: application/json' -X GET -u 'bpmsAdmin:p4ssw0rd' 'http://localhost:8080/business-central/rest/organizationalunits' | json_xs

  [
     {
        "owner" : "bpmsAdmin",
        "repositories" : [
           "helloworldrepo",
           "hw1Over"
        ],
        "defaultGroupId" : "helloworld",
        "description" : null,
        "name" : "helloworld"
     },
     {
        "repositories" : [
           "hw2Repo"
        ],
        "owner" : "bpmsAdmin - optional",
        "description" : null,
        "name" : "hw2",
        "defaultGroupId" : "hw2"
     },
     {
        "repositories" : [
           "repository1"
        ],
        "owner" : "exa...@jbpm.org",
        "description" : null,
        "name" : "example",
        "defaultGroupId" : "example"
     }
  ]


3. Extract more information about a specific repository

  curl -H 'Accept: application/json' -H 'Content-Type: application/json' -X GET -u 'bpmsAdmin:p4ssw0rd' 'http://localhost:8080/business-central/rest/repositories/hw1Over' | json_xs

  {
     "userName" : null,
     "gitURL" : "git://hw1Over",
     "requestType" : null,
     "name" : "hw1Over",
     "description" : null,
     "password" : null
  }


4. Find out about projects in a repository

  curl -H 'Accept: application/json' -H 'Content-Type: application/json' -X GET -u 'bpmsAdmin:p4ssw0rd' 'http://localhost:8080/business-central/rest/repositories/hw1Over/projects' | json_xs

  [
     {
        "version" : "1.0",
        "groupId" : "helloworld",
        "name" : "hw1OverPrj",
        "description" : "Additional Project on the helloworld:hw1Over repository"
     },
     {
        "version" : "1.0",
        "description" : "Example project based on the BRMS 6.3 Getting Started",
        "name" : "brms63start",
        "groupId" : "helloworld"
     }
  ]


5. Projects can also be created using REST

  From SoapUI:
    EndPoint: http://localhost:8080
    Resource: /business-central/rest/repositories/{repositoryTarget}/projects
    Request config: repositoryTarget/hw1Over/TEMPLATE/RESOURCE

    POST http://localhost:8080/business-central/rest/repositories/hw1Over/projects HTTP/1.1
    Accept-Encoding: gzip,deflate
    Content-Type: application/json
    Accept: application/json
    Content-Length: 64
    Host: localhost:8080
    Connection: Keep-Alive
    User-Agent: Apache-HttpClient/4.1.1 (java 1.5)
    Authorization: Basic YnBtc0FkbWluOmw0bDRrMTNzKSg=

    {"name":"testProject","description": "test project description"}

  or using curl

    curl -H 'Accept: application/json' -H 'Content-Type: application/json' -X POST -d '{"name":"prj2","description":"description2"}' -u 'bpmsAdmin:p4ssw0rd' 'http://localhost:8080/business-central/rest/repositories/hw1Over/projects' | json_xs

    {
       "description" : "description2",
       "projectVersion" : null,
       "status" : "APPROVED",
       "projectGroupId" : null,
       "repositoryName" : "hw1Over",
       "projectName" : "prj2",
       "jobId" : "1474466800973-2"
    }


6. List projects in the repository to verify creation

  curl -H 'Accept: application/json' -H 'Content-Type: application/json' -X GET -u 'bpmsAdmin:p4ssw0rd' 'http://localhost:8080/business-central/rest/repositories/hw1Over/projects' | json_xs

  [
     {
        "groupId" : "helloworld",
        "name" : "hw1OverPrj",
        "description" : "Additional Project on the helloworld:hw1Over repository",
        "version" : "1.0"
     },
     {
        "groupId" : "testProject",
        "name" : "testProject",
        "description" : "test project description",
        "version" : "1.0"
     },
     {
        "name" : "brms63start",
        "groupId" : "helloworld",
        "description" : "Example project based on the BRMS 6.3 Getting Started",
        "version" : "1.0"
     },
     {
        "name" : "prj2",
        "groupId" : "prj2",
        "version" : "1.0",
        "description" : "description2"
     }
  ]



7. Communicate with KIE server

  Before beginning communication add user and properly set system properties:
    ./add-user.sh -a --user kieserver --password kieserver1! --role kie-server,rest-all

  Typical Command/Response:
  curl -i -H 'Accept: application/json' -H 'Content-Type: application/json' -X GET -u 'kieserver':kieserver1! 'http://10.0.3.151:8080/kie-server/services/rest/server/'
  HTTP/1.1 200 OK
  Server: Apache-Coyote/1.1
  Pragma: No-cache
  Cache-Control: no-cache
  Expires: Thu, 01 Jan 1970 01:00:00 GMT
  Set-Cookie: JSESSIONIDSSO=SYm9QpCgmMNP3JKDrxTJ63mL; Path=/; HttpOnly
  Set-Cookie: JSESSIONID=+3vFmnTP3sOLHPlhj0GjTg3D; Path=/kie-server
  Content-Type: application/json
  Content-Length: 692
  Date: Fri, 23 Sep 2016 10:04:00 GMT

  {
     "type" : "SUCCESS",
     "result" : {
        "kie-server-info" : {
           "capabilities" : [
              "BRM",
              "BPM-UI",
              "BPM",
              "BRP",
              "KieServer"
           ],
           "location" : "http://10.0.3.151:8080/kie-server/services/rest/server",
           "id" : "local-server-bpm1",
           "messages" : [
              {
                 "severity" : "INFO",
                 "timestamp" : 1474625032068,
                 "content" : [
                    "Server KieServerInfo{serverId='local-server-bpm1', version='6.4.0.Final-redhat-3', location='http://10.0.3.151:8080/kie-server/services/rest/server'}started successfully at Fri Sep 23 11:03:52 BST 2016"
                 ]
              }
           ],
           "name" : "local-server-bpm1",
           "version" : "6.4.0.Final-redhat-3"
        }
     },
     "msg" : "Kie Server info"
  }


8. List available KIE containers in a remote KIE Execution Server

  in JSON format:
    curl -i -H 'Accept: application/json' -H 'Content-Type: application/json' -X GET -u 'kieserver':kieserver1! 'http://127.0.0.1:8080/kie-server/services/rest/server/containers'
    HTTP/1.1 200 OK
    Server: Apache-Coyote/1.1
    Pragma: No-cache
    Cache-Control: no-cache
    Expires: Thu, 01 Jan 1970 01:00:00 GMT
    Set-Cookie: JSESSIONIDSSO=-WRQLLKyytaLqu9EzjvDuVnf; Path=/; HttpOnly
    Set-Cookie: JSESSIONID=9kjPLgggGnp4C102ejqsAfJ7; Path=/kie-server
    Content-Type: application/json
    Content-Length: 863
    Date: Fri, 23 Sep 2016 12:13:19 GMT

    {
      "type" : "SUCCESS",
      "msg" : "List of created containers",
      "result" : {
        "kie-containers" : {
          "kie-container" : [ {
            "status" : "STARTED",
            "scanner" : {
              "status" : "DISPOSED",
              "poll-interval" : null
            },
            "messages" : [ {
              "severity" : "INFO",
              "timestamp" : 1474632746449,
              "content" : [ "Container turboContainer successfully created with module org.brms:brms63start:1.1." ]
            } ],
            "container-id" : "turboContainer",
            "release-id" : {
              "version" : "1.1",
              "group-id" : "org.brms",
              "artifact-id" : "brms63start"
            },
            "resolved-release-id" : {
              "version" : "1.1",
              "group-id" : "org.brms",
              "artifact-id" : "brms63start"
            },
            "config-items" : [ ]
          } ]
        }
      }
    }

  in XML format:
    curl -i -X GET -u 'kieserver':kieserver1! 'http://127.0.0.1:8080/kie-server/services/rest/server/containers'
    HTTP/1.1 200 OK
    Server: Apache-Coyote/1.1
    Pragma: No-cache
    Cache-Control: no-cache
    Expires: Thu, 01 Jan 1970 01:00:00 GMT
    Set-Cookie: JSESSIONIDSSO=UCnvBXyPUnenCJGYKFSNk4oK; Path=/; HttpOnly
    Set-Cookie: JSESSIONID=+JyHIKMSjSS-E7PpRymAq1K0; Path=/kie-server
    Content-Type: application/xml
    Content-Length: 984
    Date: Fri, 23 Sep 2016 12:17:49 GMT

    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <response type="SUCCESS" msg="List of created containers">
        <kie-containers>
            <kie-container container-id="turboContainer" status="STARTED">
                <messages>
                    <content>Container turboContainer successfully created with module org.brms:brms63start:1.1.</content>
                    <severity>INFO</severity>
                    <timestamp>2016-09-23T13:12:26.449+01:00</timestamp>
                </messages>
                <release-id>
                    <artifact-id>brms63start</artifact-id>
                    <group-id>org.brms</group-id>
                    <version>1.1</version>
                </release-id>
                <resolved-release-id>
                    <artifact-id>brms63start</artifact-id>
                    <group-id>org.brms</group-id>
                    <version>1.1</version>
                </resolved-release-id>
                <scanner status="DISPOSED"/>
            </kie-container>
        </kie-containers>
    </response>


9. Find out more about a specific container:

  curl -i -X GET -u 'kieserver':kieserver1! 'http://127.0.0.1:8080/kie-server/services/rest/server/containers/turboContainer'
  HTTP/1.1 200 OK
  Server: Apache-Coyote/1.1
  Pragma: No-cache
  Cache-Control: no-cache
  Expires: Thu, 01 Jan 1970 01:00:00 GMT
  Set-Cookie: JSESSIONIDSSO=4AEBSuLCQElodeGEC6Sy6erZ; Path=/; HttpOnly
  Set-Cookie: JSESSIONID=s2O1He0bThXBxYEurHjolkSO; Path=/kie-server
  X-KIE-ConversationId: %27turbo-kie-server%27%3A%27turboContainer%27%3A%27org.brms%3Abrms63start%3A1.1%27%3A%2733672fec-85f3-474f-9c21-8a1c28f0ba19%27
  Content-Type: application/xml
  Content-Length: 876
  Date: Fri, 23 Sep 2016 12:27:17 GMT

  <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
  <response type="SUCCESS" msg="Info for container turboContainer">
      <kie-container container-id="turboContainer" status="STARTED">
          <messages>
              <content>Container turboContainer successfully created with module org.brms:brms63start:1.1.</content>
              <severity>INFO</severity>
              <timestamp>2016-09-23T13:12:26.449+01:00</timestamp>
          </messages>
          <release-id>
              <artifact-id>brms63start</artifact-id>
              <group-id>org.brms</group-id>
              <version>1.1</version>
          </release-id>
          <resolved-release-id>
              <artifact-id>brms63start</artifact-id>
              <group-id>org.brms</group-id>
              <version>1.1</version>
          </resolved-release-id>
          <scanner status="DISPOSED"/>
      </kie-container>
  </response>


10. Insert an object, fire-all-rules and get results

  Refer to "BRMS Getting Started" guide for the implementation of the rule for this example.

  Refer to "BPM.6.3 Development Guide - 16.5.7 / 16.5.6.3/4" for more details of the commands.

  curl -X POST -H 'X-KIE-ContentType: JSON' -H 'Content-type: application/json' -u 'kieserver:kieserver1!' --data @a http://localhost:8080/kie-server/services/rest/server/containers/instances/turboContainer

  Using file "a"
  +----
  |  {
  |    "lookup" : "brms63KSession",
  |    "commands" : [
  |      {
  |        "insert" : {
  |          "object" : { "org.brms.brms63start.Person": { "firstName":"brainy", "lastName":"pinky", "hourlyRate":12, "wage":200 } }
  |        }
  |      },
  |      { "fire-all-rules" : { } }
  |    ]
  |  }
  +----

  results in:
  {
    "type" : "SUCCESS",
    "msg" : "Container turboContainer successfully called.",
    "result" : {
      "execution-results" : {
        "results" : [ ],
        "facts" : [ ]
      }
    }
  }

  check in the "stdout" of the EAP/BPM.6.3 for the output of the fire-all-rules.
  In this case:

  14:44:14,825 INFO  [stdout] (http-127.0.0.1:8080-7) Hello brainy pinky!
  14:44:14,825 INFO  [stdout] (http-127.0.0.1:8080-7) You seem well off, will you marry me?


11. Get a list of all objects from the current session

  CAVEAT: Request must be in XSTREAM format to allow from proper deserialization of results
          Note difference in HTTP headers

  curl -X POST -H 'X-KIE-ContentType: XSTREAM' -H 'Content-type: application/json' -u 'kieserver:kieserver1!' -d'<batch-execution lookup="brms63KSession"><get-objects out-identifier="hive"/></batch-execution>' http://localhost:8080/kie-server/services/rest/server/containers/instances/turboContainer

  <?xml version="1.0"?>
  <org.kie.server.api.model.ServiceResponse>
    <type>SUCCESS</type>
    <msg>Container turboContainer successfully called.</msg>
    <result class="execution-results">
      <result identifier="hive">
        <list>
          <org.brms.brms63start.Person>
            <firstName>brainy</firstName>
            <lastName>pinky</lastName>
            <hourlyRate>12</hourlyRate>
            <wage>200</wage>
          </org.brms.brms63start.Person>
          <org.brms.brms63start.Person>
            <firstName>brainy</firstName>
            <lastName>pinky</lastName>
            <hourlyRate>12</hourlyRate>
            <wage>200</wage>
          </org.brms.brms63start.Person>
          <org.brms.brms63start.Person>
            <firstName>brainy</firstName>
            <lastName>pinky</lastName>
            <hourlyRate>12</hourlyRate>
            <wage>200</wage>
          </org.brms.brms63start.Person>
        </list>
      </result>
    </result>
  </org.kie.server.api.model.ServiceResponse>


12. Insert an object and get its fact handle along with the result:

  curl -X POST -H 'X-KIE-ContentType: JSON' -H 'Content-type: application/json' -u 'kieserver:kieserver1!' --data @a ttp://localhost:8080/kie-server/services/rest/server/containers/instances/turboContainer

  Using file "a":
  +----
  |  {
  |    "lookup" : "brms63KSession",
  |    "commands" : [
  |      {
  |        "insert" : {
  |          "object" : { "org.brms.brms63start.Person": { "firstName":"MARVIN", "lastName":"GoldenHeart", "hourlyRate":20, "wage":200 } },
  |          "out-identifier":"brainy"
  |        }
  |      },
  |      { "fire-all-rules" : { } }
  |    ]
  |  }
  +----

  Result:
  {
     "type" : "SUCCESS",
     "result" : {
        "execution-results" : {
           "results" : [
              {
                 "key" : "brainy",
                 "value" : {
                    "org.brms.brms63start.Person" : {
                       "wage" : 200,
                       "firstName" : "MARVIN",
                       "lastName" : "GoldenHeart",
                       "hourlyRate" : 20
                    }
                 }
              }
           ],
           "facts" : [
              {
                 "key" : "brainy",
                 "value" : {
                    "org.drools.core.common.DefaultFactHandle" : {
                       "external-form" : "0:6:198440441:198440441:6:DEFAULT:NON_TRAIT:org.brms.brms63start.Person"
                    }
                 }
              }
           ]
        }
     },
     "msg" : "Container turboContainer successfully called."
  }


13. Using the above fact-handle, retract the object:

  curl -X POST -H 'X-KIE-ContentType: XSTREAM' -H 'Content-type: application/json' -u 'kieserver:kieserver1!' -d'<batch-execution lookup="brms63KSession"><retract fact-handle="0:6:198440441:198440441:6:DEFAULT:NON_TRAIT:org.brms.brms63start.Person"/></batch-execution>' http://localhost:8080/kie-server/services/rest/server/containers/instances/turboContainer

  <?xml version="1.0"?>
  <org.kie.server.api.model.ServiceResponse>
    <type>SUCCESS</type>
    <msg>Container turboContainer successfully called.</msg>
    <result class="execution-results"/>
  </org.kie.server.api.model.ServiceResponse>


14. check this out:

  curl -s  -X POST -H 'X-KIE-ContentType: JSON' -H 'Content-type: application/json' -u 'kieserver:kieserver1!' --data @a http://localhost:8080/kie-server/services/rest/server/containers/instances/turboContainer | jq -r '.result["execution-results"].facts[].value["org.drools.core.common.DefaultFactHandle"]["external-form"]'


15. Compile project

  curl -s -X POST -H 'Accept: application/json' -H 'Content-Type: application/json' -u 'bpmsAdmin:p4ssw0rd' 'http://localhost:8080/business-central/rest//repositories/hw1Over/projects/brms63start/maven/compile'

  {
     "projectName" : "brms63start",
     "repositoryName" : "hw1Over",
     "jobId" : "1474881688742-5",
     "status" : "APPROVED"
  }


16. Get status of compile job by JobId:

  curl -s -X GET -H 'Accept: application/json' -H 'Content-Type: application/json' -u 'bpmsAdmin:p4ssw0rd' 'http://localhost:8080/business-central/rest/jobs/1474881688742-5'

  A sample successfull response:
  {
     "result" : null,
     "lastModified" : 1474881689437,
     "status" : "SUCCESS",
     "detailedResult" : [
        "level:INFO, path:null, text:Build of project 'brms63start' (requested by system) completed.\n Build: SUCCESSFUL"
     ],
     "jobId" : "1474881688742-5"
  }

  Given the following DRL:
  package org.brms.brms63start;

  rule "brms63start Rule"
  when
    Person ( hourlyRate * wage > 100, name : firstName, surname : lastName )
  then
    System.out.println( "----!" );
    System.out.println( "Hello" + " " + name + " " + surname + "!" );
    System.out.println( "Did you get your towel?" );
    wrong
  end

  A sample failed response due to DRL syntax error:
  {
   "jobId" : "1474885110609-25",
   "result" : null,
   "detailedResult" : [
      "level:INFO, path:null, text:Build of project 'brms63start' (requested by system) completed.\n Build: FAILURE",
      "level:ERROR, path:PathImpl{uri='default://master@hw1Over/brms63start/src/main/resources/org/brms/brms63start/brms63Rule.drl', fileName='brms63Rule.drl', attrs={}}, text:Rule Compilation error Syntax error, insert \"VariableDeclarators\" to complete LocalVariableDeclaration\nSyntax error, insert \";\" to complete LocalVariableDeclarationStatement\nwrong cannot be resolved to a type"
   ],
   "lastModified" : 1474885111023,
   "status" : "FAIL"
}


  A sample failed response:
  {
     "result" : null,
     "jobId" : "1474882315812-7",
     "status" : "FAIL",
     "lastModified" : 1474882318853,
     "detailedResult" : [
        "level:ERROR, path:null, text:Deployment of unit org.brms:brms63start:1.4 failed: java.lang.RuntimeException: java.lang.IllegalStateException: Cannot find ksession, either it does not exist or there are multiple default ksession in kmodule.xml",
        "artifactID:brms63start, groupId:org.brms, version:1.4"
     ]
  }


17. Use the following sequence to check on compilation/deploy status:

  curl -s -X POST -H 'Accept: application/json' -H 'Content-Type: application/json' -u 'bpmsAdmin:p4ssw0rd' 'http://localhost:8080/business-central/rest//repositories/hw1Over/projects/brms63start/maven/compile' | jq -r '.jobId' > /tmp/jobid; job=`cat /tmp/jobid`; echo $job; for i in `seq 0 10`; do echo -n '.'; sleep 1s; done; echo; curl -s -X GET -H 'Accept: application/json' -H 'Content-Type: application/json' -u 'bpmsAdmin:p4ssw0rd' "http://localhost:8080/business-central/rest/jobs/$job" | json_pp



     {
         "capabilities" : [
            "RULE",
            "PROCESS",
            "PLANNING"
         ],
         "server-config" : {},
         "server-name" : "turbo-kie-server",
         "server-id" : "turbo-kie-server",
         "server-instances" : [
            {
               "server-name" : "turbo-ki...@127.0.0.1:8080",
               "server-url" : "http://127.0.0.1:8080/kie-server/services/rest/server",
               "server-template-id" : "turbo-kie-server",
               "server-instance-id" : "turbo-ki...@127.0.0.1:8080"
            }
         ],
         "container-specs" : [
            {
               "configuration" : {
                  "RULE" : {
                     "org.kie.server.controller.api.model.spec.RuleConfig" : {
                        "pollInterval" : null,
                        "scannerStatus" : "STOPPED"
                     }
                  },
                  "PROCESS" : {
                     "org.kie.server.controller.api.model.spec.ProcessConfig" : {
                        "kbase" : "",
                        "ksession" : "",
                        "mergeMode" : "KEEP_ALL",
                        "runtimeStrategy" : "PER_PROCESS_INSTANCE"
                     }
                  }
               },
               "server-template-key" : {
                  "server-id" : "turbo-kie-server",
                  "server-name" : "turbo-kie-server"
               },
               "container-name" : "turboContainer",
               "release-id" : {
                  "artifact-id" : "brms63start",
                  "version" : "1.27",
                  "group-id" : "org.brms"
               },
               "status" : "STARTED",
               "container-id" : "turboContainer"
            }
         ]

Grant Ferguson

unread,
Oct 13, 2016, 9:21:16 AM10/13/16
to Drools Usage, Grant.F...@fmr.com
Hi Ged,

Thanks for sharing that link. While that top section in the doc (10.6.1) does give some more detail about headers you have to put in, it still is significantly lacking in documentation. For example - after section 10.6.1 - the documentation jumps strait to the process api and managing processes with the REST API, but not the BRMS portion of the product. In later sections, there is some documentation about managing the KIE server containers, but not executing rules.

I'm essentially looking for documentation that highlights the appropriate commands that can be sent to the KIE server REST api for rule execution, and their appropriate parameters. I have been unable to find this from RedHat, JBoss, KIE, etc. 

Everything that I have found to-date about how to call the KIE server and execute rules has been through random googling and other users sharing their REST api calls. 

Here are some random examples of other pieces of software, and their REST api documentation, similar to what I am hoping I can find for executing rules on KIE server.



Thanks,
Grant 

ASHISH NATHANI

unread,
Jul 26, 2017, 3:05:04 AM7/26/17
to Drools Usage, Grant.F...@fmr.com
Hi Ged,

I have set up kie server and workbench on my system and I am able to fire the rules through rest calls now . But I am facing two major issue and these are  when I update the rule I need to create a new container with new version for that rule and secondly when I create the new container  it is not instantiated and for that I need to restart my server .
Is there any way through which I can update and deploy new / modified rules at run time

Thanks in advance

Regards
Ashish Nathani

Ged Byrne

unread,
Jul 26, 2017, 7:48:11 AM7/26/17
to Drools Usage, Grant.F...@fmr.com
Hi Ashish,

The way that Drools handles Rules deployment is clever and versatile but can take some getting used.  It's tied closely into Maven and I won't attempt to explain it in an email.

I'd recommend Mastering JBoss Rules 6 because it has a good explanation of how KieScanner and KieJars work.  The relevant part is available as a preview on Google Books: https://books.google.it/books?id=CZnjCwAAQBAJ&lpg=PA56&ots=NKXm2xNuFt&dq=kiejars&pg=PA54#v=onepage&q=kiejars&f=false 

Regards, 


Ged

--
You received this message because you are subscribed to a topic in the Google Groups "Drools Usage" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/drools-usage/If_bM_mNJnE/unsubscribe.
To unsubscribe from this group and all its topics, send an email to drools-usage...@googlegroups.com.
To post to this group, send email to drools...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/drools-usage/dbe5a834-c503-49a1-aca3-fc9e4bec213b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Hemant Jain

unread,
Nov 3, 2017, 7:17:31 AM11/3/17
to Drools Usage
Hi, 

i have created a drl file and i am going to call my drl file through rest but first time response is correct but second time i click on send button the response is merged (Old response+ new response) we can say duplicate response.

example: response 1: when i click first time send button

<org.kie.server.api.model.ServiceResponse>
  <type>SUCCESS</type>
  <msg>Container assignmentDemoContainer successfully called.</msg>
  <result class="execution-results">
    <result identifier="retfinalscore">
      <query-results>
        <identifiers>
          <identifier>retfinalscore</identifier>
        </identifiers>
        <row>
          <identifier id="retfinalscore">
            <assignmentdemo.assignmentdemoproj.CalculateTotalScoreTable>
              <max__Mob__All>10.0</max__Mob__All>
              <util__Curr__Cc__Tot>10.0</util__Curr__Cc__Tot>
              <avg__Util__Curr__All__Tot>10.0</avg__Util__Curr__All__Tot>
              <mobScore>25.0</mobScore>
              <utilScore>25.0</utilScore>
              <avgUtilScore>15.0</avgUtilScore>
              <finalScore>65.0</finalScore>
            </assignmentdemo.assignmentdemoproj.CalculateTotalScoreTable>
            <fact-handle external-form="0:1:1469900987:1469900987:59:DEFAULT:NON_TRAIT:assignmentdemo.assignmentdemoproj.CalculateTotalScoreTable"/>
          </identifier>
        </row>
        <row>
          <identifier id="retfinalscore">
            <assignmentdemo.assignmentdemoproj.CalculateTotalScoreTable>
              <max__Mob__All>20.0</max__Mob__All>
              <util__Curr__Cc__Tot>20.0</util__Curr__Cc__Tot>
              <avg__Util__Curr__All__Tot>20.0</avg__Util__Curr__All__Tot>
              <mobScore>30.0</mobScore>
              <utilScore>25.0</utilScore>
              <avgUtilScore>15.0</avgUtilScore>
              <finalScore>70.0</finalScore>
            </assignmentdemo.assignmentdemoproj.CalculateTotalScoreTable>
            <fact-handle external-form="0:2:886912960:886912960:58:DEFAULT:NON_TRAIT:assignmentdemo.assignmentdemoproj.CalculateTotalScoreTable"/>
          </identifier>
        </row>
        <row>
          <identifier id="retfinalscore">
            <assignmentdemo.assignmentdemoproj.CalculateTotalScoreTable>
              <max__Mob__All>30.0</max__Mob__All>
              <util__Curr__Cc__Tot>30.0</util__Curr__Cc__Tot>
              <avg__Util__Curr__All__Tot>30.0</avg__Util__Curr__All__Tot>
              <mobScore>35.0</mobScore>
              <utilScore>30.0</utilScore>
              <avgUtilScore>20.0</avgUtilScore>
              <finalScore>85.0</finalScore>
            </assignmentdemo.assignmentdemoproj.CalculateTotalScoreTable>
            <fact-handle external-form="0:3:32046540:32046540:57:DEFAULT:NON_TRAIT:assignmentdemo.assignmentdemoproj.CalculateTotalScoreTable"/>
          </identifier>
        </row>
        <row>
          <identifier id="retfinalscore">
            <assignmentdemo.assignmentdemoproj.CalculateTotalScoreTable>
              <max__Mob__All>40.0</max__Mob__All>
              <util__Curr__Cc__Tot>40.0</util__Curr__Cc__Tot>
              <avg__Util__Curr__All__Tot>40.0</avg__Util__Curr__All__Tot>
              <mobScore>35.0</mobScore>
              <utilScore>30.0</utilScore>
              <avgUtilScore>20.0</avgUtilScore>
              <finalScore>85.0</finalScore>
            </assignmentdemo.assignmentdemoproj.CalculateTotalScoreTable>
            <fact-handle external-form="0:4:1651289453:1651289453:56:DEFAULT:NON_TRAIT:assignmentdemo.assignmentdemoproj.CalculateTotalScoreTable"/>
          </identifier>
        </row>
      </query-results>
    </result>
  </result>
</org.kie.server.api.model.ServiceResponse>




example 2: when i click second time send button

<org.kie.server.api.model.ServiceResponse>
  <type>SUCCESS</type>
  <msg>Container assignmentDemoContainer successfully called.</msg>
  <result class="execution-results">
    <result identifier="retfinalscore">
      <query-results>
        <identifiers>
          <identifier>retfinalscore</identifier>
        </identifiers>
        <row>
          <identifier id="retfinalscore">
            <assignmentdemo.assignmentdemoproj.CalculateTotalScoreTable>
              <max__Mob__All>10.0</max__Mob__All>
              <util__Curr__Cc__Tot>10.0</util__Curr__Cc__Tot>
              <avg__Util__Curr__All__Tot>10.0</avg__Util__Curr__All__Tot>
              <mobScore>25.0</mobScore>
              <utilScore>25.0</utilScore>
              <avgUtilScore>15.0</avgUtilScore>
              <finalScore>65.0</finalScore>
            </assignmentdemo.assignmentdemoproj.CalculateTotalScoreTable>
            <fact-handle external-form="0:57:920695976:920695976:68:DEFAULT:NON_TRAIT:assignmentdemo.assignmentdemoproj.CalculateTotalScoreTable"/>
          </identifier>
        </row>
        <row>
          <identifier id="retfinalscore">
            <assignmentdemo.assignmentdemoproj.CalculateTotalScoreTable>
              <max__Mob__All>20.0</max__Mob__All>
              <util__Curr__Cc__Tot>20.0</util__Curr__Cc__Tot>
              <avg__Util__Curr__All__Tot>20.0</avg__Util__Curr__All__Tot>
              <mobScore>30.0</mobScore>
              <utilScore>25.0</utilScore>
              <avgUtilScore>15.0</avgUtilScore>
              <finalScore>70.0</finalScore>
            </assignmentdemo.assignmentdemoproj.CalculateTotalScoreTable>
            <fact-handle external-form="0:58:1917648715:1917648715:67:DEFAULT:NON_TRAIT:assignmentdemo.assignmentdemoproj.CalculateTotalScoreTable"/>
          </identifier>
        </row>
        <row>
          <identifier id="retfinalscore">
            <assignmentdemo.assignmentdemoproj.CalculateTotalScoreTable>
              <max__Mob__All>30.0</max__Mob__All>
              <util__Curr__Cc__Tot>30.0</util__Curr__Cc__Tot>
              <avg__Util__Curr__All__Tot>30.0</avg__Util__Curr__All__Tot>
              <mobScore>35.0</mobScore>
              <utilScore>30.0</utilScore>
              <avgUtilScore>20.0</avgUtilScore>
              <finalScore>85.0</finalScore>
            </assignmentdemo.assignmentdemoproj.CalculateTotalScoreTable>
            <fact-handle external-form="0:59:2049837396:2049837396:66:DEFAULT:NON_TRAIT:assignmentdemo.assignmentdemoproj.CalculateTotalScoreTable"/>
          </identifier>
        </row>
        <row>
          <identifier id="retfinalscore">
            <assignmentdemo.assignmentdemoproj.CalculateTotalScoreTable>
              <max__Mob__All>40.0</max__Mob__All>
              <util__Curr__Cc__Tot>40.0</util__Curr__Cc__Tot>
              <avg__Util__Curr__All__Tot>40.0</avg__Util__Curr__All__Tot>
              <mobScore>35.0</mobScore>
              <utilScore>30.0</utilScore>
              <avgUtilScore>20.0</avgUtilScore>
              <finalScore>85.0</finalScore>
            </assignmentdemo.assignmentdemoproj.CalculateTotalScoreTable>
            <fact-handle external-form="0:60:1540285532:1540285532:65:DEFAULT:NON_TRAIT:assignmentdemo.assignmentdemoproj.CalculateTotalScoreTable"/>
          </identifier>
        </row>
        <row>
          <identifier id="retfinalscore">
            <assignmentdemo.assignmentdemoproj.CalculateTotalScoreTable>
              <max__Mob__All>10.0</max__Mob__All>
              <util__Curr__Cc__Tot>10.0</util__Curr__Cc__Tot>
              <avg__Util__Curr__All__Tot>10.0</avg__Util__Curr__All__Tot>
              <mobScore>25.0</mobScore>
              <utilScore>25.0</utilScore>
              <avgUtilScore>15.0</avgUtilScore>
              <finalScore>65.0</finalScore>
            </assignmentdemo.assignmentdemoproj.CalculateTotalScoreTable>
            <fact-handle external-form="0:1:1469900987:1469900987:59:DEFAULT:NON_TRAIT:assignmentdemo.assignmentdemoproj.CalculateTotalScoreTable"/>
          </identifier>
        </row>
        <row>
          <identifier id="retfinalscore">
            <assignmentdemo.assignmentdemoproj.CalculateTotalScoreTable>
              <max__Mob__All>20.0</max__Mob__All>
              <util__Curr__Cc__Tot>20.0</util__Curr__Cc__Tot>
              <avg__Util__Curr__All__Tot>20.0</avg__Util__Curr__All__Tot>
              <mobScore>30.0</mobScore>
              <utilScore>25.0</utilScore>
              <avgUtilScore>15.0</avgUtilScore>
              <finalScore>70.0</finalScore>
            </assignmentdemo.assignmentdemoproj.CalculateTotalScoreTable>
            <fact-handle external-form="0:2:886912960:886912960:58:DEFAULT:NON_TRAIT:assignmentdemo.assignmentdemoproj.CalculateTotalScoreTable"/>
          </identifier>
        </row>
        <row>
          <identifier id="retfinalscore">
            <assignmentdemo.assignmentdemoproj.CalculateTotalScoreTable>
              <max__Mob__All>30.0</max__Mob__All>
              <util__Curr__Cc__Tot>30.0</util__Curr__Cc__Tot>
              <avg__Util__Curr__All__Tot>30.0</avg__Util__Curr__All__Tot>
              <mobScore>35.0</mobScore>
              <utilScore>30.0</utilScore>
              <avgUtilScore>20.0</avgUtilScore>
              <finalScore>85.0</finalScore>
            </assignmentdemo.assignmentdemoproj.CalculateTotalScoreTable>
            <fact-handle external-form="0:3:32046540:32046540:57:DEFAULT:NON_TRAIT:assignmentdemo.assignmentdemoproj.CalculateTotalScoreTable"/>
          </identifier>
        </row>
        <row>
          <identifier id="retfinalscore">
            <assignmentdemo.assignmentdemoproj.CalculateTotalScoreTable>
              <max__Mob__All>40.0</max__Mob__All>
              <util__Curr__Cc__Tot>40.0</util__Curr__Cc__Tot>
              <avg__Util__Curr__All__Tot>40.0</avg__Util__Curr__All__Tot>
              <mobScore>35.0</mobScore>
              <utilScore>30.0</utilScore>
              <avgUtilScore>20.0</avgUtilScore>
              <finalScore>85.0</finalScore>
            </assignmentdemo.assignmentdemoproj.CalculateTotalScoreTable>
            <fact-handle external-form="0:4:1651289453:1651289453:56:DEFAULT:NON_TRAIT:assignmentdemo.assignmentdemoproj.CalculateTotalScoreTable"/>
          </identifier>
        </row>
      </query-results>
    </result>
  </result>
</org.kie.server.api.model.ServiceResponse>




please help me out thanks in advance.
 
IMP_URLS.txt

Ged Byrne

unread,
Nov 4, 2017, 9:35:08 AM11/4/17
to Drools Usage
The important thing to understand is that what you get the back into so much the results of your request more of a snapshot of what’s in working memory.

The first request create an application demo fact so you get that back in the results.

The second request creates another application demo so you get that back.

However, you haven’t deleted your first fact so it’s still in working memory. That means that you get that back too.

It looks to me like your using a query request to return all application demo facts. If this is the case you have two options

1. Add some rules to ensure there is only ever one instance in working memory.  
2. Make the query more specific.  For example add a Request ID and include it as a query parameter. 

The first option is simpler but the second keeps a history.  I’ve used both approaches.  

Regards,


Ged

--
You received this message because you are subscribed to a topic in the Google Groups "Drools Usage" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/drools-usage/If_bM_mNJnE/unsubscribe.
To unsubscribe from this group and all its topics, send an email to drools-usage...@googlegroups.com.
To post to this group, send email to drools...@googlegroups.com.

Hemant Jain

unread,
Nov 6, 2017, 2:54:39 AM11/6/17
to Drools Usage
please provide example of above two points.

i have attached my DRL file please review it and send me a proper suggestion.

 
 
DRL.txt

Ged Byrne

unread,
Nov 6, 2017, 3:02:23 AM11/6/17
to drools...@googlegroups.com
Where do you create CalculateTotalScoreTable() object?
On Mon, 6 Nov 2017 at 07:54, Hemant Jain <hemant...@gmail.com> wrote:
please provide example of above two points.

i have attached my DRL file please review it and send me a proper suggestion.

 
 

--
You received this message because you are subscribed to a topic in the Google Groups "Drools Usage" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/drools-usage/If_bM_mNJnE/unsubscribe.
To unsubscribe from this group and all its topics, send an email to drools-usage...@googlegroups.com.
To post to this group, send email to drools...@googlegroups.com.

Hemant Jain

unread,
Nov 6, 2017, 4:19:02 AM11/6/17
to Drools Usage
please find the attachment.

i have created the CalculateTotalScoreTable() in dataobject section of JBOSS BRMS.
DataObject.txt

Ged Byrne

unread,
Nov 6, 2017, 7:19:55 AM11/6/17
to drools...@googlegroups.com
That is where you define the class, but where do you create the instances?

Somewhere in a Java or DRL file you create a new data object and then insert it into working memory.

Perhaps you are not doing it directly, instead calling a service.


Hemant Jain

unread,
Nov 7, 2017, 2:29:53 AM11/7/17
to Drools Usage
i have already create a instance in DRL file please check and update on this.
DRL.txt

Ged Byrne

unread,
Nov 7, 2017, 10:54:42 AM11/7/17
to drools...@googlegroups.com

The object is not created inside the Drl.

The rule has the following LHS:

when

$calculateTotalScore :
CalculateTotalScoreTable

This means that it is invoked when the CalculateScoreTable is inserted into the fact base.

Where is the code that does that insertion?

Hemant Jain

unread,
Nov 8, 2017, 5:01:37 AM11/8/17
to Drools Usage
Thanks Ged.



I want t create a batch request for regression in BRMS,can you help me how i can create a batch in brms for regression of all rules testing.
a.txt

Ged Byrne

unread,
Nov 8, 2017, 7:18:35 AM11/8/17
to drools...@googlegroups.com
I'm sorry but I'm not going to do that.

There's a guide to batch execution using Camel here: https://docs.jboss.org/drools/release/6.2.0.CR3/drools-docs/html/ch.camel.html 

I would also recommend the Drool's Developer's Cookbook: https://www.packtpub.com/application-development/drools-developer%E2%80%99s-cookbook 

You should look at Chapter 6 - Executing Drools Remotely.

Hemant Jain

unread,
Nov 9, 2017, 1:12:41 AM11/9/17
to Drools Usage
Thank You so much.
Reply all
Reply to author
Forward
0 new messages