Chapter 23. Configuring a service and KIE Server to emit Kafka messages when a transaction is committed
You can configure KIE Server to emit Kafka messages automatically. In this case, KIE Server sends a message every time a task, process, case, or variable is created, updated, or deleted. The Kafka message contains information about the modified object. KIE Server sends the message when it commits the transaction with the change.
You can use this functionality with any business process or case. You do not need to change anything in the process design.
This configuration is also available if you run your process service using SpringBoot.
By default, KIE Server publishes the messages in the following topics:
-
jbpm-processes-events
for messages about completed processes -
jbpm-tasks-events
for messages about completed tasks -
jbpm-cases-events
for messages about completed cases
You can configure the topic names.
The published messages comply with the CloudEvents specification version 1.0. Each message contains the following fields:
-
id
: The unique identifier of the event -
type
: The type of the event (process, task, or case) -
source
: The event source as a URI -
time
: The timestamp of the event, by default in the RFC3339 format -
data
: Information about the process, case, or task, presented in a JSON format
Procedure
To enable emitting Kafka messages, complete one of the following steps:
If you deployed KIE Server on Red Hat JBoss EAP or another application server, complete the following steps:
-
Download the
rhpam-7.12.0-maven-repository.zip
product deliverable file from the Software Downloads page of the Red Hat Customer Portal. - Extract the contents of the file.
-
Copy the
maven-repository/org/jbpm/jbpm-event-emitters-kafka/7.59.0.Final-redhat-00006/jbpm-event-emitters-kafka-7.59.0.Final-redhat-00006.jar
file into thedeployments/kie-server.war/WEB-INF/lib
subdirectory of the application server.
-
Download the
If you deployed the application using SpringBoot, add the following lines to the
<dependencies>
list in thepom.xml
file of your service:<dependency> <groupId>org.jbpm</groupId> <artifactId>jbpm-event-emitters-kafka</artifactId> <version>${version.org.kie}</version> </dependency>
Configure any of the following KIE Server system properties as necessary:
-
org.kie.jbpm.event.emitters.kafka.bootstrap.servers
: The host and port of the Kafka broker. The default value islocalhost:9092
. You can use a comma-separated list of multiple host:port pairs. -
org.kie.jbpm.event.emitters.kafka.date_format
: The timestamp format for thetime
field of the messages. The default value isyyyy-MM-dd’T’HH:mm:ss.SSSZ
. -
org.kie.jbpm.event.emitters.kafka.topic.processes
: The topic name for process event messages. The default value isjbpm-processes-events
. -
org.kie.jbpm.event.emitters.kafka.topic.cases
: The topic name for process event messages. The default value isjbpm-cases-events
. -
org.kie.jbpm.event.emitters.kafka.topic.tasks
: The topic name for process event messages. The default value isjbpm-processes-tasks
. -
org.kie.jbpm.event.emitters.kafka.client.id
: An identifier string to pass to the server when making requests. The server uses this string for logging. org.kie.jbpm.event.emitters.kafka.property_name
: You can set any Red Hat AMQ Streams consumer or producer property by using theorg.kie.jbpm.event.emitters.kafka
prefix. For example, to set a value for thebuffer.memory
producer property, set theorg.kie.jbpm.event.emitters.kafka.buffer.memory
KIE Server system property.This setting applies when the KIE Server emits Kafka messages automatically when completing transactions.
For a list of Red Hat AMQ Streams consumer and producer properties, see the Consumer configuration parameters and Producer configuration parameters appendixes in Using AMQ Streams on RHEL.
-