简介

drools是一个规则引擎组件,而drools-workbench也是KIE组件中的元素,也称为KIR-WB,是一个可视化的规则编辑器。
官方提供了war包,可以通过wildfly部署(7.x版本前还可以部署Tomcat,7.x后不支持了);同时提供了Docker安装

文中安装使用的Mac M1,如果是windows,执行和配置脚本从sh换成bat即可


wildfly安装

下载wildfly

下载地址:https://docs.wildfly.org/
因为是java8,所以下载的是21.0.0.Final版本,放到本地一个目录后,一些启动与配置思路可以类比Tomcat。

1、修改启动参数
wildfly部署drools-workbench,默认的内存不够用,需要修改内存
进入 ${wildfly_home}/bin目录,编辑standalone.conf
将默认内存配置:

JAVA_OPTS=-Xms64M -Xmx512M -XX:MetaspaceSize=96M -XX:MaxMetaspaceSize=256m

修改为:

JAVA_OPTS=-Xms256M -Xmx1024M -XX:MetaspaceSize=96M -XX:MaxMetaspaceSize=512m

如果部署后有中文乱码,可以追加-Dfile.encoding=UTF-8参数


2、添加用户
2.1、进入 ${wildfly_home}/bin目录,执行 sh add-user.sh,进入交互式操作添加admin管理用户

# 选择添加管理员账户,输入a
What type of user do you wish to add?
 a) Management User (mgmt-users.properties)
 b) Application User (application-users.properties)
(a): a
 
Enter the details of the new user to add.
Using realm 'ManagementRealm' as discovered from the existing property files.
 
# 输入管理员账户,输入admin(这里选择admin,注意admin是默认账户,所以此处意思修改admin用户,因为新安装的wildfly并不知道amdin用户的密码)
Username : admin
 
# 选择修改admin账户,输入a
User 'admin' already exists and is disabled, would you like to...
 a) Update the existing user password and roles
 b) Enable the existing user
 c) Type a new username
(a): a
 
Password recommendations are listed below. To modify these restrictions edit the add-user.properties configuration file.
 - The password should be different from the username
 - The password should not be one of the following restricted values {root, admin, administrator}
 - The password should contain at least 8 characters, 1 alphabetic character(s), 1 digit(s), 1 non-alphanumeric symbol(s)
# 输入admin用户密码
Password :
WFLYDM0098: The password should be different from the username
Are you sure you want to use the password entered yes/no? yes
 
# 输入admin确认密码
Re-enter Password :
 
# 输入admin用户所属组(注意输入admin)
What groups do you want this user to belong to? (Please enter a comma separated list, or leave blank for none)[  ]: admin
 
# 输入yes
Updated user 'admin' to file 'D:\wildfly-23.0.0.Final\standalone\configuration\mgmt-users.properties'
Updated user 'admin' to file 'D:\wildfly-23.0.0.Final\domain\configuration\mgmt-users.properties'
Updated user 'admin' with groups admin to file 'D:\wildfly-23.0.0.Final\standalone\configuration\mgmt-groups.properties'
Updated user 'admin' with groups admin to file 'D:\wildfly-23.0.0.Final\domain\configuration\mgmt-groups.properties'
Is this new user going to be used for one AS process to connect to another AS process?
e.g. for a slave host controller connecting to the master or for a Remoting connection for server to server Jakarta Enterprise Beans calls.
yes/no? yes
To represent the user add the following to the server-identities definition <secret value="YWRtaW4=" />

2.2、再次执行 sh add-user.sh,进入交互式操作添加应用用户账号

# 选择添加应用类型的用户,输入b
What type of user do you wish to add?
 a) Management User (mgmt-users.properties)
 b) Application User (application-users.properties)
(a): b
Enter the details of the new user to add.
Using realm 'ApplicationRealm' as discovered from the existing property files.

# 输入用户名(随便输入,如workbench)
Username : workbench
Password recommendations are listed below. To modify these restrictions edit the
 add-user.properties configuration file.
 - The password should be different from the username
 - The password should not be one of the following restricted values {root, admi
n, administrator}
 - The password should contain at least 8 characters, 1 alphabetic character(s),
 1 digit(s), 1 non-alphanumeric symbol(s)

#输入密码
Password :
WFLYDM0098: The password should be different from the username
Are you sure you want to use the password entered yes/no? yes

#输入确认密码
Re-enter Password :

# 输入用户所属组(这里一定要填写admin,否则后续用户无法登录drools-workbench应用)
What groups do you want this user to belong to? (Please enter a comma separated
list, or leave blank for none)[  ]: admin

# 输入yes回车
About to add user 'workbench' for realm 'ApplicationRealm'
Is this correct yes/no? yes

# 输入yes回车
Added user 'workbench' to file 'D:\wildfly-23.0.0.Final\standalone\configuration
\application-users.properties'
Added user 'workbench' to file 'D:\wildfly-23.0.0.Final\domain\configuration\app
lication-users.properties'
Added user 'workbench' with groups admin to file 'D:\wildfly-23.0.0.Final\standa
lone\configuration\application-roles.properties'
Added user 'workbench' with groups admin to file 'D:\wildfly-23.0.0.Final\domain
\configuration\application-roles.properties'
Is this new user going to be used for one AS process to connect to another AS pr
ocess?
e.g. for a slave host controller connecting to the master or for a Remoting conn
ection for server to server Jakarta Enterprise Beans calls.
yes/no? yes
To represent the user add the following to the server-identities definition <sec
ret value="d29ya2JlbmNo" />

至此,配置wildfly完成。

下载drools-workbench

到drools官网,下载地址:https://www.drools.org/download/download.html
此处下载的是7.x版本,对应的 Business Central Workbench,点击最后一列的(WildFly 23 WAR)完成下载

WildFly版本不对应,不影响部署,此处应该是最高可部署版本 WildFly 23。

image-1670984997035

部署

将下载的drools-workbench包 copy到 ${wildfly_home}/standalone/deployments 目录下,也可以将drools-workbench war重新命个名。

进入${wildfly_home}/bin目录,执行 sh standalone.sh 完成启动部署。

访问:http://127.0.0.1:9990,输入admin用户名与密码
进入wildfly首页,选择部署应用
image-1670984863075

输入workbench应用名与密码
image-1670984885155

成功登录
image-1670984912521


docker部署失败记录

使用dockers安装一直没成功,可能是M1系统的原因,先安装做个记录吧。

没有docker环境的先下载个docker环境

拉取镜像

根据jboss发布的最新镜像安装:business-central-workbench-showcase
镜像地址:https://hub.docker.com/r/jboss/business-central-workbench-showcase

使用 -showcase 是因为其内置了默认的配置

运行镜像

docker run -p 8080:8080 -p 8001:8001 -d --name jbpm-workbench quay.io/kiegroup/business-central-workbench-showcase:latest

映射8080端口,命名 jbpm-workbench

因为是mac M1系统,可能提示警告:WARNING: The requested image’s platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested
可以添加:–platform linux/amd64
docker run --platform linux/amd64 -p 8080:8080 -p 8001:8001 -d --name jbpm-workbench quay.io/kiegroup/business-central-workbench-showcase:latest

访问

http://127.0.0.1:8080/business-central

同理可以通过docker镜像安装kie-server

docker一些命令

拉取镜像:docker pull
查看镜像:docker images
查看启动的容器:docker ps
查看全部容器:docker ps -a
看日志:docker logs 容器id
进入容器:docker exec -it 容器id /bash/bin
停止启动的容器:docker stop/kill 容器id
删除停止的容器:docker rm 容器id