setup drools Kie execution server credentials

♀尐吖头ヾ 提交于 2019-11-30 07:51:32

问题


I'm trying to setup the kie execution service (kie-server-services-6.2.0) for being provisioned by the kie-drools-wb-webapp-6.2.0, when I try to get access by following the webapp url of the execution server it shows a BASIC authentication, and don't know how to proceed for getting the access to the execution server, and also get the endpoint url, for provisioning the build-in rules examples of the kie-wb and get the REST or the WSDL working. The kie-wb has a username with role "admin" and I can build correctly the rules. Many thanks!!


回答1:


Trying to answer you question I decided to create HOWTO from the very beginning what I did to get my Drool rules executed on remote server.

My task was to integrate Kie Workbench and Execution Server, so business users be able to create Drools rules and deploy them to the Repo, while developers could use these rules via calling REST services of standalone Drools execution server.

You should follow these steps:

Before using Drools Execution Server let me use such terminology:

  • Kie Drools Workbench - is UI for creating and deploying Model and Rules file(s) to Maven Repository
  • Kie Execution Server - is standalone Drools execution server. It consumes REST calls of commands and returns execution results
  • Assumed you have Tomcat 7.0/8.0 and Maven installed

Deployment of Drools Workbench

Most stable version of Kie Drools Workbench to deploy at the moment is 6.1.0.Final. Use this one for deploying on Tomcat 7.0 only!

  • You can download file called kie-drools-wb-distribution-wars from Jboss sonar repo, use version 6.1.0.Final and tomcat7.war

  • Make sure you added following jars to Tomcat's lib directory: javax.security.jacc-api-1.4.jar, kie-tomcat-integration.jar, slf4j-api-1.7.2.jar

  • Make sure you have or added following roles/users to tomcat-users.xml of your Tomcat:

<role rolename="admin"/> <!-- Tomcat Admin role -->
<role rolename="analyst"/> <!-- Kie Workbench Analyst role. -->
<role rolename="kie-server"/> <!-- Kie Drools Execution Server role. Needed to make REST Rules execution request -->
<user username="admin" password="admin" roles="manager-gui,manager-script" /> <!-- Tomcat Admin user -->
<user username="user1" password="user1" roles="admin, kie-server" /> <!-- Kie Drools Execution Server user. Needed to make REST Rules execution request -->
  • Deploy tomcat7.war to Tomcat. I'm sure you know how to make it
  • Open link: http://localhost:8080/kie-drools-wb-distribution-wars-6.1.0.Final-tomcat7.0/. Use admin credentials configured in previous step to enter Workbench. In our case user1/user1
  • In Kie Workbench create a Model, Rules file. Validate them and click Deploy. Make sure you have jar file with your project being put to Maven repo!

    As an example you can use rule and model I created for testing purposes: Drool rule file:

    import com.arty.drlwb.MyExampleType;
    
    rule "one"
    when 
    MyExampleType(message == "Hello Worlddddd")
    then
    System.out.println("Hello World:)");
    end
    

Deployment of Kie Drools Execution Server

For the moment of this To-Do writing the most stable version of Kie Drools Execution Server is kie-server-services-6.2.0.Beta3.war. You can download it here, Jboss sonar repo:

  • Deploy kie-server-services-6.2.0.Beta3.war on Tomcat
  • Make GET request on http://localhost:8080/kie-server-services-6.2.0.Beta3/services/rest/server/. If you asked to provide user/password use one you've configured for kie-server role in tomcat-users.xml. You should see same response:

    <response type="SUCCESS" msg="Kie Server info">
      <kie-server-info>
      <version>6.2.0.Beta3</version>
      </kie-server-info>
    </response>
  • If you see the same result as I see, now its time to deploy kie container: Make PUT request at http://localhost:8080/kie-server-services-6.2.0.Beta3/services/rest/server/containers/{your_container_id} Use this XML format:

<kie-container>
       <container-id>{your_container_id}</container-id>
       <status/> 
       <release-id>
            <group-id>{your_project_group_id}</group-id>
            <artifact-id>{your_project_artifact_id}</artifact-id>
            <version>{your_project_version}</version>
      </release-id>
     <resolved-release-id/>
</kie-container>
  • If you get SUCCESS status response you can check now all containers have been deployed. Make GET on http://localhost:8080/kie-server-services-6.2.0.Beta3/services/rest/server/containers. You should see your container been deployed:

<response type="SUCCESS" msg="List of created containers">
 <kie-containers>
 <kie-container container-id="{your_container_id}" status="STARTED">
 <release-id>
<artifact-id>{your_project_artifact_id}</artifact-id>
<group-id>{your_project_group_id}</group-id>
<version>{your_project_version}</version>
</release-id>
 <resolved-release-id>
<artifact-id>{your_project_artifact_id}</artifact-id>
<group-id>{your_project_group_id}</group-id>
<version>{your_project_version}</version>
</resolved-release-id>
</kie-container>
</kie-containers>
</response>
  • Now launch all rules you've created and put to your project jar: Make POST request at http://localhost:8080/kie-server-services-6.2.0.Beta3/services/rest/server/containers/{your_container_id}

Use XML format. of cause use your own model instead of MyExampleType:

<batch-execution lookup="defaultKieSession">
<insert out-identifier="message" return-object="true" entry-point="DEFAULT">
    <com.arty.drlwb.MyExampleType>
          <message>Hello Worlddddd</message>
    </com.arty.drlwb.MyExampleType>
</insert>
<fire-all-rules/>
</batch-execution>
  • Check your Tomcat console. If you get Hello World:) message and SUCCESS response type all works for you now!

P.S Due to luck of documentation about the topic I checked out Server's sources from GitHub. Take a look at kie-server-client and kie-server-integ-tests code and tests. Hope this helps.



来源:https://stackoverflow.com/questions/26551535/setup-drools-kie-execution-server-credentials

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!