Producing messages on Kafka topics
You can use the KafkaProducer node to connect to the Kafka messaging system and publish messages on Kafka topics.
Before you begin
About this task
You can use the KafkaProducer node to publish messages that are generated from within your message flow to a topic that is hosted on a Kafka server. The published messages are then available to be received by consumers (subscribers) reading from the topic.
You can use a KafkaConsumer node in a message flow to subscribe to a specified topic on a Kafka server. You can also use a KafkaRead node to read an individual message on a specified topic. For more information about using these nodes, see Consuming messages from Kafka topics and Reading an individual message from a Kafka topic.
You can configure the KafkaProducer node to publish messages transactionally or
non-transactionally. When the KafkaProducer node operates
non-transactionally, messages that are published are immediately available to the message consumers.
If you set the Acks property on the KafkaProducer node to 1 or All,
the KafkaProducer node waits for confirmation that the
message was successfully received by the Kafka server before it continues in the flow. Failure to
receive confirmation does not guarantee that the messages failed to be delivered to consumers. If
this property is set to All, the KafkaProducer waits for confirmation from all replicas of the topic. This option provides the strongest
available guarantee that the record was received. When Acks is enabled, the
offset of the message that is published is stored in the local environment.
When the
KafkaProducer node operates transactionally, messages that
are published are not available to KafkaConsumer nodes that
are configured with the Isolation level parameter set to
read_committed unless the transaction is committed at the end of the message flow.
If the message flows ends with an exception, the transaction is rolled-back and KafkaConsumer nodes that are configured with the
read_committed option do not receive the message. KafkaConsumer nodes that are configured with
read_uncommitted receive the messages even if they are subsequently rolled-back.
When a transactional KafkaProducer node is operating in a
message flow that was started with a transactional KafkaConsumer node that has the same value for the
Transactional Id parameter, the saving of the consumer position and the
publishing of messages can be enabled to occur within the same transaction. For a KafkaConsumer node and a KafkaProducer node to use the same transaction in this way, their
configurations must have matching values for significant node properties, such as
Bootstrap servers and Client ID. These values are
compared, and the publish operation is rejected with an appropriate error message if differences are
found.
You can use Kafka custom header properties to add metadata to Kafka messages for use
during message processing. These properties are set in the LocalEnvironment, in a folder called
KafkaHeader. For more information, see Setting and retrieving Kafka custom header properties.
Procedure
Complete the following steps to use IBM App Connect Enterprise to publish messages to a topic on a Kafka server: