17.9. 在 Red Hat Process Automation Manager 中的独立数据库模式中保留进程变量
当您创建在您定义的进程中使用的进程变量时,Red Hat Process Automation Manager 会将这些进程变量存储为默认数据库 schema 中的二进制数据。您可以在单独的数据库架构中保留进程变量,以便在维护和实施进程数据方面具有更大的灵活性。
例如,在单独的数据库架构中保留进程变量可帮助您执行以下任务:
- 以人类可读格式维护进程变量
- 将变量提供给 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 图标,并配置持久性行为:
图 17.1. Business Central 中的持久性配置
在项目的
pom.xml
文件中,添加以下依赖项以实现持久性支持。此依赖关系包含您在数据对象中配置的VariableEntity
类。持久性的项目依赖项
Copy to Clipboard Copied! Toggle word wrap Toggle overflow 在项目的
~/META-INF/kie-descriptor.xml
文件中,配置 JPA marshalling 策略和与 marshaller 搭配使用的持久性单元。JPA marshalling 策略和持久性单元需要定义为实体的对象。在 kie-deployment-descriptor.xml 文件中配置的 JPA marshaller 和持久性单元
<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
文件,该文件指定要保留 process 变量的数据源:带有数据源配置的 persistence.xml 文件示例
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - 1
- 设置进程变量保留的数据源
要使用 Business Central 配置 marshalling 策略、持久性单元和数据源,请导航到项目 Settings
Deployments Marshalling Strategy 和 project Settings Persistence : 图 17.2. 在 Business Central 中的 JPA marshaller 配置
图 17.3. Business Central 中的持久性单元和数据源配置