Example code for the Cadence Kafka Blog demonstrating how to integrate sending a message to Apache Kafka and getting a reply back using Uber Cadence workflows, with support for both signal-based and activity-completion-based reply patterns.
This project showcases two approaches for integrating Apache Kafka with Cadence workflows:
- Signal-based replies: The Kafka consumer sends a Cadence signal back to the originating workflow using the workflow ID from message headers.
- Activity-completion-based replies: The Kafka consumer completes an outstanding Cadence activity using a task token from message headers.
The demo starts 10 parallel workflows that each send a message to a Kafka topic and then wait for a reply. A separate Kafka consumer reads these messages and sends replies back to Cadence using the appropriate method.
- Configure your Kafka broker IPs and credentials in
consumer.propertiesandproducer.properties. - Update the Cadence host IP address in the Java source files.
- Build the project using Maven:
mvn clean install
- Run the Kafka Consumer class first:
java -cp target/*.jar BlogCadenceKafkaExample_KafkaConsumer - Run the Cadence workflow class with either signal or activity completions flag set to
true/false:java -cp target/*.jar BlogCadenceKafkaExample_Cadence
The Kafka consumer detects whether the reply should be sent via signal or activity completion based on message headers.
- Java 8 or higher
- Apache Maven for building the project
- Apache Kafka cluster (e.g., Instaclustr managed Kafka) with auto topic creation enabled
- Cadence server (e.g., Instaclustr managed Cadence)
- The IP address of the machine running the code must be added to both Kafka and Cadence cluster firewall configurations
- Kafka broker IPs, username, and password configured in
consumer.propertiesandproducer.properties - Cadence host IP set in the Java source files
This project is intended to run as a local demo against remote Kafka and Cadence clusters. To deploy:
- Provision an Instaclustr Kafka cluster with SASL authentication and auto topic creation enabled.
- Provision an Instaclustr Cadence cluster.
- Add your client machine's IP to the allowed firewall rules for both clusters.
- Update the properties files and source code with your cluster connection details.
- Build and run the consumer and workflow classes as described in Getting Started.
- Paul Brebner - Initial work - NetApp Instaclustr
See also the list of MAINTAINERS who participated in projects in this repository.
This project is licensed under the MIT License - see the LICENSE.md file for details