此内容没有您所选择的语言版本。
Chapter 10. Replicating audit data in a JMS message broker
You can replicate KIE Server audit data to a Java Message Service (JMS) message broker, for example ActiveMQ or Artemis, and then dump the data in an external database schema so that you can improve the performance of your Spring Boot application by deleting the audit data from your application schema.
If you configure your application to replicate data in a message broker, when an event occurs in KIE Server the record of that event is stored in the KIE Server database schema and it is sent to the message broker. You can then configure an external service to consume the message broker data into an exact replica of the application’s database schema. The data is appended in the message broker and the external database every time an event is produce by KIE Server.
Only audit data is stored in the message broker. No other data is replicated.
Prerequisites
- You have an existing Red Hat Process Automation Manager Spring Boot project.
Procedure
-
Open the Spring Boot application’s
pom.xml
file in a text editor. Add the KIE Server Spring Boot audit dependency to the
pom.xml
file:<dependency> <groupId>org.kie</groupId> <artifactId>kie-server-spring-boot-autoconfiguration-audit-replication</artifactId> <version>${version.org.kie}</version> </dependency>
Add the dependency for your JMS client. The following example adds the Advanced Message Queuing Protocol (AMQP) dependency:
<dependency> <groupId>org.amqphub.spring</groupId> <artifactId>amqp-10-jms-spring-boot-starter</artifactId> <version>2.2.6</version> </dependency>
Add the JMS pool dependency:
<dependency> <groupId>org.messaginghub</groupId> <artifactId>pooled-jms</artifactId> </dependency>
To configure KIE Server audit replication to use queues, complete the following tasks:
Add the following lines to your Spring Boot application’s
application.properties
file:kieserver.audit-replication.producer=true kieserver.audit-replication.queue=audit-queue
Add the properties required for your message broker client. The following example shows how to configure KIE Server for AMPQ, where
<JMS_HOST_PORT>
is the port that the broker listens on and<USERNAME>
and<PASSWORD
are the login credentials for the broker:amqphub.amqp10jms.remote-url=amqp://<JMS_HOST_PORT> amqphub.amqp10jms.username=<USERNAME> amqphub.amqp10jms.password=<PASSWORD> amqphub.amqp10jms.pool.enabled=true
Add the following lines to the
application.properties
file of the service that will consume the message broker data:kieserver.audit-replication.consumer=true kieserver.audit-replication.queue=audit-queue
Add the properties required for your message broker client to the
application.properties
file of the service that will consume the message broker data. The following example shows how to configure KIE Server for AMPQ, where<JMS_HOST_PORT>
is the port that your message broker listens on and<USERNAME>
and<PASSWORD>
are the login credentials for the message broker:amqphub.amqp10jms.remote-url=amqp://<JMS_HOST_PORT> amqphub.amqp10jms.username=<USERNAME> amqphub.amqp10jms.password=<PASSWORD> amqphub.amqp10jms.pool.enabled=true
To configure KIE Server audit replication to use topics, complete the following tasks:
Add the following lines to your Spring Boot application’s
application.properties
file:kieserver.audit-replication.producer=true kieserver.audit-replication.topic=audit-topic
Add the properties required for your message broker client to the
application.properties
file of the service that will consume the message broker data. The following example shows how to configure KIE Server for AMPQ, where<JMS_HOST_PORT>
is the port that your message broker listens on and<USERNAME>
and<PASSWORD
are the login credentials for the message broker:spring.jms.pub-sub-domain=true amqphub.amqp10jms.remote-url=amqp://<JMS_HOST_PORT> amqphub.amqp10jms.username=<USERNAME> amqphub.amqp10jms.password=<PASSWORD> amqphub.amqp10jms.pool.enabled=true
Add the following lines to the
application.properties
file of the service that will consume the message broker data:kieserver.audit-replication.consumer=true kieserver.audit-replication.topic=audit-topic::jbpm kieserver.audit-replication.topic.subscriber=jbpm spring.jms.pub-sub-domain=true
Add the properties required for your message broker client to the
application.properties
file of the service that will consume the message broker data. The following example shows how to configure KIE Server for AMPQ, where<JMS_HOST_PORT>
is the port that your message broker listens on and<USERNAME>
and<PASSWORD>
are the login credentials for the message broker:amqphub.amqp10jms.remote-url=amqp://<JMS_HOST_PORT> amqphub.amqp10jms.username=<USERNAME> amqphub.amqp10jms.password=<PASSWORD> amqphub.amqp10jms.pool.enabled=true amqphub.amqp10jms.clientId=jbpm
Optional: To configure the KIE Server that contains the replicated data to be read only, set the
org.kie.server.rest.mode.readonly
property in theapplication.properties
file totrue
:org.kie.server.rest.mode.readonly=true
Additional resources
10.1. Spring Boot JMS audit replication parameters
The following table describes the parameters used to configure JMS audit replication for Red Hat Process Automation Manager applications on Spring Boot.
Parameter | Values | Description |
---|---|---|
|
| Specifies whether the business application will act as a producer to replicate and send the JMS messages to either a queue or a topic. |
|
| Specifies whether the business application will act as a consumer to receive the JMS messages from either a queue or a topic. |
|
| The name of the JMS queue to either send or consume messages. |
|
| The name of the JMS topic to either send or consume messages. |
|
| The name of the topic subscriber. |
|
| Specifies read only mode for the business application. |