此内容没有您所选择的语言版本。
Chapter 22. Configuring KIE Server to send and receive Kafka messages from the process
To run a process that sends or receives Kafka messages using events, you must use KIE Server. You must configure the KIE Server instance to integrate with Red Hat AMQ Streams.
Prerequisites
- A KIE Server instance is installed.
Procedure
To enable integration with Red Hat AMQ Streams, set the following system properties according to your environment:
-
If you are using KIE Server on Red Hat JBoss EAP, set the
org.kie.kafka.server.ext.disabledKIE Server system property of tofalse. -
If you are using Spring Boot, set the
kieserver.kafka.enabledsystem property totrue.
-
If you are using KIE Server on Red Hat JBoss EAP, set the
-
To configure the connection to the Kafka broker, set the
org.kie.server.jbpm-kafka.ext.bootstrap.serverssystem property to the host and port of the broker. The default value islocalhost:9092. You can use a comma-separated list of multiple host:port pairs. Optional: Set any of the following system properties related to both sending and receiving Kafka messages:
Expand Table 22.1. Optional KIE Server system properties related to both sending and receiving Kafka messages Property Description org.kie.server.jbpm-kafka.ext.client.idAn identifier string to pass to the broker when making requests. Red Hat AMQ Streams uses this string for logging.
org.kie.server.jbpm-kafka.ext.topics.*Mapping of message names to topic names. For example, if you want to send or receive a message in the
ExampleTopictopic whenExampleNameis the name of the message, set theorg.kie.server.jbpm-kafka.ext.topics.ExampleNamesystem property toExampleTopic. You can set any number of such system properties. If a message name is not mapped using a system property, the process engine uses this name as the topic name.org.kie.server.jbpm-kafka.ext.property_nameSet any Red Hat AMQ Streams consumer or producer property by using the
org.kie.server.jbpm-kafka.extprefix. For example, to set a value for thebuffer.memoryproducer property, set theorg.kie.server.jbpm-kafka.ext.buffer.memoryKIE Server system property.This setting applies to all processes that send or receive Kafka messages using events on this KIE Server.
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.
Optional: Set any of the following system properties related to receiving Kafka messages:
Expand Table 22.2. Optional KIE Server system properties related to receiving Kafka messages Property Description Default value org.kie.server.jbpm-kafka.ext.allow.auto.create.topicsAllow automatic topic creation.
trueorg.kie.server.jbpm-kafka.ext.group.idA unique string that identifies the group to which this Kafka message consumer belongs.
jbpm-consumer.Optional: Set any of the following system properties related to sending Kafka messages:
Expand Table 22.3. Optional KIE Server system properties related to sending Kafka messages Property Description Default value org.kie.server.jbpm-kafka.ext.acksThe number of acknowledgements that the Kafka leader must receive before marking the request as complete.
1. This value means the leader writes the record to its local log and then responds to the process engine, without waiting for full acknowledgement from all followers.org.kie.server.jbpm-kafka.ext.max.block.msThe number of milliseconds for which the publish method blocks. After this time, the process engine can resume execution of the business process.
2000(2 seconds).
22.1. Configuring the use a custom message format 复制链接链接已复制到粘贴板!
By default, when using message events, the process engine sends and receives messages in a format compliant with the CloudEvents specification version 1.0.
Optionally, you can configure the use of a raw JSON data format or a custom format for the messages. If you want to use a custom format, you need to implement and provide classes.
Prerequisites
- Your project uses message events to send or receive messages.
Procedure
If you want to use a custom format for sending or receiving messages, implement and provide custom classes:
Develop the source code for the classes:
-
To send messages, develop a class that implements the
KafkaEventWriterinterface To receive messages, develop a class that implements the
KafkaEventReaderinterfaceYou can download the interface definitons from the GitHub repository.
-
To send messages, develop a class that implements the
- Provide the classes to your business application. For instructions, see Chapter 24, Providing a custom class to your business application in Business Central.
Set the following KIE Server system properties to set the custom writer or reader:
Expand Table 22.4. KIE Server system properties for setting a custom writer or reader Property Description org.kie.server.jbpm-kafka.ext.eventWriterClassThe custom event writer class. Set this property to use a different format to send messages. If you want to use a custom format, set the property to the fully qualified name of your custom event writer class. If you want to use a raw JSON data format, set the property to
org.kie.server.services.jbpm.kafka.RawJsonEventWriter.org.kie.server.jbpm-kafka.ext.eventReaderClassThe custom event reader class. Set this property to use a different format to receive messages. If you want to use a custom format, set the property to the fully qualified name of your custom event reader class. If you want to use a raw JSON data format, set the property to
org.kie.server.services.jbpm.kafka.RawJsonEventReader.