Chapter 22. Configuring a KIE Server to send and receive Kafka messages from the process
To run a process that sends or receives Kafka messages (except when using the custom task), you must use a KIE Server. You must configure this KIE Server to integrate with Red Hat AMQ Streams.
To enable integration with Red Hat AMQ Streams, set the following system properties according to your environment:
If you are using the KIE Server on Red Hat JBoss EAP, set the
org.kie.kafka.server.ext.disabledsystem property of the KIE Server to
If you are using Spring Boot, set the
kieserver.kafka.enabledsystem property to
- If you are using the 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 is
localhost:9092. You can use a comma-separated list of multiple host:port pairs.
Optional: Set any of the following system properties to configure sending and receiving Kafka messages:
org.kie.server.jbpm-kafka.ext.client.id: An 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
ExampleNameis the name of the message, set the
org.kie.server.jbpm-kafka.ext.topics.ExampleNamesystem property to
ExampleTopic. 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.
Optional: Set any of the following system properties to configure receiving Kafka messages:
org.kie.server.jbpm-kafka.ext.allow.auto.create.topics: Allow automatic topic creation. Enabled by default.
org.kie.server.jbpm-kafka.ext.group.id: A unique string that identifies the group to which this Kafka message consumer belongs. The default value is
Optional: Set any of the following system properties to configure sending Kafka messages:
org.kie.server.jbpm-kafka.ext.acks: The number of acknowledgements that the Kafka leader must receive before marking the request as complete. The default value is
1, which 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.ms: The number of milliseconds for which the publish method blocks. After this time, the process engine can resume execution of the business process. The default value is
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.
- Your project uses message events to send or receive messages.
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
To receive messages, develop a class that implements the
You 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:
org.kie.server.jbpm-kafka.ext.eventWriterClass: the 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.jbpm-kafka.ext.eventReaderClass: the 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