Skip to main content
Here are some tips, including the required configurations and code samples, to help you implement a Kafka producer in Java.

Required dependencies

Ensure that you have the following dependencies in your project:

Configuration

Ensure that you have the following configuration in your application.yml or application.properties file:

Code sample for a Kafka producer

Ensure that you have the necessary KafkaTemplate bean autowired in your producer class. The sendMessage method demonstrates how to send a message to a Kafka topic with the specified headers and payload. Make sure to include all the received Kafka headers in the response that is sent back to the FlowX Engine.

Kafka headers

Understanding Kafka headers in FlowX Integration

When integrating with FlowX Engine via Kafka, headers play a crucial role in message routing and processing. It’s essential to preserve and include all received headers in responses back to the FlowX Engine.
Need help finding identifier values? Check out the Finding Identifiers and Parameters guide to learn where to locate workspace IDs, application IDs, build IDs, process instance UUIDs, and other identifiers in FlowX Designer.

Important headers

Planning to upgrade to 5.9 LTS?5.9.0 makes Fx-Organization-Id mandatory on every Kafka message. Custom Kafka producers that don’t send it will be rejected with a non-retryable MissingKafkaHeaderException. Review the Migrating from 5.1 LTS guide before upgrading.

The fxContext header explained

The fxContext header is particularly important for routing messages in architectures with embedded processes and subprocesses:
  • For kafka-receive nodes in the root process: fxContext = "main"
  • For an embedded subprocess with nodeId=4: fxContext = "main:4"
  • For an embedded sub-subprocess with nodeId=12: fxContext = "main:4:12"
This hierarchical format ensures messages are delivered to their intended recipients within the process structure.

Understanding Fx-RootAppId

The Fx-RootAppId header is used to track the originating application throughout the entire process chain. This is particularly important when:
  • Multiple applications are involved in a workflow
  • Processes spawn subprocesses across different components
  • You need to trace a complete transaction back to its originating application
Unlike Fx-AppId which may change as a message passes through different components, Fx-RootAppId preserves the original initiator’s identity.

Best Practices

  1. Preserve All Headers: Always include all received Kafka headers in responses to the FlowX Engine.
Last modified on May 18, 2026