18.9. 在 Red Hat Process Automation Manager 中保留独立数据库模式中的进程变量
当您在您定义的进程内创建进程变量时,Red Hat Process Automation Manager 会将这些进程变量存储为二进制数据存储在默认数据库架构中。您可以在单独的数据库模式中保留进程变量,以便在维护和实施进程数据方面具有更大的灵活性。
例如,在单独的数据库模式中保留您的进程变量可帮助您执行以下任务:
- 以人类可读格式维护进程变量
- 使变量可供 Red Hat Process Automation Manager 之外的服务使用
- 清除 Red Hat Process Automation Manager 中默认数据库表的日志,而不丢失进程变量数据
此流程只适用于进程变量。此流程不适用于问题单变量。
先决条件
- 您已在 Red Hat Process Automation Manager 中定义了要实施变量的进程。
- 如果要在 Red Hat Process Automation Manager 之外的数据库模式中保留变量,则已创建了数据源以及您要使用的独立数据库模式。有关创建数据源的详情,请参考 配置 Business Central 设置和属性。
流程
在用作进程变量的数据对象文件中,添加以下元素来配置变量持久性:
为变量持久性配置的 Person.java 对象示例
Copy to Clipboard Copied! Toggle word wrap Toggle overflow 要使数据对象持久使用 Business Central,进入项目中的数据对象文件,点窗口右上角的 Persistence 图标,并配置持久性行为:
图 18.1. Business Central 中的持久性配置
在项目的
pom.xml
文件中,添加以下持久性支持依赖项。此依赖项包含您在数据对象中配置的变量
类。项目持久性依赖项
Copy to Clipboard Copied! Toggle word wrap Toggle overflow 在项目的
~/META-INF/kie-deployment-descriptor.xml
文件中,配置 JPA marshalling 策略和持久性单元,以用于 marshaller。对于定义为实体的对象,需要 JPA marshalling 策略和持久性单元。在 kie-deployment-descriptor.xml 文件中配置的 JPA marshaller 和 persistence 单元
<marshalling-strategy> <resolver>mvel</resolver> <identifier>new org.drools.persistence.jpa.marshaller.JPAPlaceholderResolverStrategy("myPersistenceUnit", classLoader)</identifier> <parameters/> </marshalling-strategy>
<marshalling-strategy> <resolver>mvel</resolver> <identifier>new org.drools.persistence.jpa.marshaller.JPAPlaceholderResolverStrategy("myPersistenceUnit", classLoader)</identifier> <parameters/> </marshalling-strategy>
Copy to Clipboard Copied! Toggle word wrap Toggle overflow 在项目的
~/META-INF
目录中,创建一个persistence.xml
文件,用于指定您要保留进程变量的数据源:带有数据源配置的 persistence.xml 文件示例
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - 1
- 设置保留进程变量的数据源
要使用 Business Central 配置 marshalling 策略、持久性单元和数据源,请导航到 Project Settings
Deployments Marshalling Policies and to project Settings Persistence : 图 18.2. Business Central 中的 JPA marshaller 配置
图 18.3. Business Central 中的持久性单元和数据源配置