이 콘텐츠는 선택한 언어로 제공되지 않습니다.
Chapter 23. Configuring a service and KIE Server to send Kafka messages when a transaction is committed
You can configure KIE Server with an emitter that sends 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-eventsfor messages about completed processes -
jbpm-tasks-eventsfor messages about completed tasks -
jbpm-cases-eventsfor 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
Prerequisites
- A KIE Server instance is installed.
Procedure
To send Kafka messages automatically, complete one of the following tasks:
If you deployed KIE Server on Red Hat JBoss EAP or another application server, complete the following steps:
-
Download the
rhpam-7.13.5-maven-repository.zipproduct 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.67.0.Final-redhat-00024/jbpm-event-emitters-kafka-7.67.0.Final-redhat-00024.jarfile into thedeployments/kie-server.war/WEB-INF/libsubdirectory of the application server.
-
Download the
If you deployed the application using SpringBoot, add the following lines to the
<dependencies>list in thepom.xmlfile of your service:<dependency> <groupId>org.jbpm</groupId> <artifactId>jbpm-event-emitters-kafka</artifactId> <version>${version.org.kie}</version> </dependency><dependency> <groupId>org.jbpm</groupId> <artifactId>jbpm-event-emitters-kafka</artifactId> <version>${version.org.kie}</version> </dependency>Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Configure any of the following KIE Server system properties as necessary:
Expand Table 23.1. KIE Server system properties related to the Kafka emitter Property Description Default value org.kie.jbpm.event.emitters.kafka.bootstrap.servers:The host and port of the Kafka broker. You can use a comma-separated list of multiple host:port pairs.
localhost:9092org.kie.jbpm.event.emitters.kafka.date_format:The timestamp format for the
timefield of the messages.yyyy-MM-dd’T’HH:mm:ss.SSSZorg.kie.jbpm.event.emitters.kafka.topic.processesThe topic name for process event messages.
jbpm-processes-eventsorg.kie.jbpm.event.emitters.kafka.topic.casesThe topic name for case event messages.
jbpm-cases-eventsorg.kie.jbpm.event.emitters.kafka.topic.tasksThe topic name for task event messages.
jbpm-processes-tasksorg.kie.jbpm.event.emitters.kafka.client.idAn identifier string to pass to the server when making requests. The server uses this string for logging.
org.kie.jbpm.event.emitters.kafka.property_nameSet any Red Hat AMQ Streams consumer or producer property by using this prefix. For example, to set a value for the
buffer.memoryproducer property, set theorg.kie.jbpm.event.emitters.kafka.buffer.memoryKIE Server system property.This setting applies when KIE Server is configured with an emitter to send 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.
org.kie.jbpm.event.emitters.eagerInitBy default, KIE Server initializes the Kafka emitter only when sending a message. If you want to initialize the Kafka emitter when KIE Server starts, set this property to
true.When KIE Server initializes the Kafka emitter, it logs any errors in Kafka emitter configuration and any Kafka communication errors. If you set the
org.kie.jbpm.event.emitters.eagerInitproperty totrue, any such errors appear in the log output when KIE Server starts.false