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. Note 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>USD{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: 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: Add the following lines to the application.properties file of the service that will consume the message broker data: 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: 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: 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: Add the following lines to the application.properties file of the service that will consume the message broker data: 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: 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 the application.properties file to true : Additional resources Section 10.1, "Spring Boot JMS audit replication parameters" 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. Table 10.1. Spring Boot JMS audit replication parameters Parameter Values Description kieserver.audit-replication.producer true, false Specifies whether the business application will act as a producer to replicate and send the JMS messages to either a queue or a topic. kieserver.audit-replication.consumer true, false Specifies whether the business application will act as a consumer to receive the JMS messages from either a queue or a topic. kieserver.audit-replication.queue string The name of the JMS queue to either send or consume messages. kieserver.audit-replication.topic string The name of the JMS topic to either send or consume messages. kieserver.audit-replication.topic.subscriber string The name of the topic subscriber. org.kie.server.rest.mode.readonly true, false Specifies read only mode for the business application.

Commands:
<dependency> <groupId>org.kie</groupId> <artifactId>kie-server-spring-boot-autoconfiguration-audit-replication</artifactId> <version>USD{version.org.kie}</version> </dependency>
<dependency> <groupId>org.amqphub.spring</groupId> <artifactId>amqp-10-jms-spring-boot-starter</artifactId> <version>2.2.6</version> </dependency>
<dependency> <groupId>org.messaginghub</groupId> <artifactId>pooled-jms</artifactId> </dependency>
kieserver.audit-replication.producer=true kieserver.audit-replication.queue=audit-queue
amqphub.amqp10jms.remote-url=amqp://<JMS_HOST_PORT> amqphub.amqp10jms.username=<USERNAME> amqphub.amqp10jms.password=<PASSWORD> amqphub.amqp10jms.pool.enabled=true
kieserver.audit-replication.consumer=true kieserver.audit-replication.queue=audit-queue
amqphub.amqp10jms.remote-url=amqp://<JMS_HOST_PORT> amqphub.amqp10jms.username=<USERNAME> amqphub.amqp10jms.password=<PASSWORD> amqphub.amqp10jms.pool.enabled=true
kieserver.audit-replication.producer=true kieserver.audit-replication.topic=audit-topic
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
kieserver.audit-replication.consumer=true kieserver.audit-replication.topic=audit-topic::jbpm kieserver.audit-replication.topic.subscriber=jbpm 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 amqphub.amqp10jms.clientId=jbpm
org.kie.server.rest.mode.readonly=true