Skip to Content
IntegrationsApache Kafka

Apache Kafka

Collection KAFKA_CONSUMER and Delivery KAFKA_PRODUCE. It is the way to take plant data to the data team — which usually asks “send it to a Kafka topic” — and to bring events from there into CMS.

On the Connections screen, the Apache Kafka type sits in the Messaging category, next to RabbitMQ and Azure Service Bus. MQTT stays under Industrial Protocols.

Connection

Apache Kafka connection: service, bootstrap, security and Schema Registry
Apache Kafka connection: service, bootstrap, security and Schema Registry
Apache Kafka connection: service, bootstrap, security and Schema Registry

A single Connection serves five services. The Service field is not cosmetic: it changes the defaults and the validations on the screen.

ServiceWhat changes
Apache Kafka (self-hosted)No restriction
Confluent CloudOnly accepts SASL_SSL + PLAIN. User and password are the API key and API secret of the cluster — not the account ones
Azure Event Hubs (Kafka endpoint)Only accepts SASL_SSL + PLAIN on port 9093. The user is always $ConnectionString; the password is the namespace connection string (Shared access policies)
Amazon MSKSCRAM or client certificate (mTLS, port 9094)
RedpandaSpeaks the Kafka protocol; same configuration as Apache Kafka
FieldWhat it is for
Bootstrap servershost:port, comma-separated (broker1:9092,broker2:9092)
Client IDName CMS uses to introduce itself to the cluster
Security protocolPLAINTEXT, SSL, SASL_PLAINTEXT or SASL_SSL
SASL mechanismPLAIN, SCRAM-SHA-256 or SCRAM-SHA-512
Username / PasswordSASL credential. On the cloud services, the screen swaps the labels (API key, Connection string)
Validate TLS certificate / CA certificatePEM of the CA that signs the brokers’ certificate. Empty = the system’s public CAs, the case for cloud services
Client certificate (mTLS) / Client private key (mTLS)Only for certificate authentication. Fill in both or neither; the key is stored encrypted
Timeout (ms)Maximum time for connecting and for a response
Schema Registry (URL, user, password)Optional, needed only for Avro. Confluent API (also Redpanda’s and Apicurio’s in compatibility mode)

On Confluent Cloud, the Schema Registry has another API key, different from the cluster’s. Using the same one in both places is the most common cause of “the Schema Registry rejected the credentials”.

Test Connection answers with the service and how many topics the credential sees — Connected to Confluent Cloud — 12 visible topic(s) — and, with a Schema Registry, how many subjects it has.

Advertised address. After bootstrap, the client starts talking to the address each broker advertises (advertised.listeners). On Docker and Kubernetes that address is often an internal name CMS cannot resolve: bootstrap answers, and the connection fails right after. CMS recognises the case and says which address was advertised — set advertised.listeners on the broker to an address CMS can reach.

With the Connection linked to an Application, the Kafka Keep Alive follows the cluster. A Collection going down raises the Kafka connection lost alert.

Collection — KAFKA_CONSUMER

The Collection is push: it stays subscribed to the topic and every record read becomes a message in CMS.

FieldWhat it is for
Topic(s)One topic, or several separated by commas. The magnifier lists the topics the credential sees in the cluster — tick one or more. Accepts a {{NAME}} Variable, resolved when the Collection starts
Consumer groupThe Kafka group.id. Empty = cms-<APPLICATION>-<COLLECTION>
Start reading fromNew messages only or From the beginning of the topic. Only applies while the group has no committed position in the topic yet; after that, reading always continues where it stopped
Value formatText (JSON, XML, CSV…), which arrives as is, or Avro (Schema Registry), decoded with the schema referenced in the record itself and delivered as JSON
Include record metadataOn, the message becomes {topic, partition, offset, timestamp, key, headers, value}. Off, it is just the value. The metadata is recorded under “Sent” either way

The group is the reading position

The reading position belongs to the group, not to the Collection. Two consequences:

  • Changing the group name restarts reading, from whatever Start reading from says.
  • Two consumers in the same group split the partitions — each one sees only part of the messages. The screen warns when the group already has active consumers outside CMS, and CMS refuses two of its own Collections in the same group of the same cluster.

Nothing is lost while CMS is down

The offset is only committed to Kafka after the message has been stored in CMS. If the CMS database is down, the Collection waits and rereads the same record. The guarantee is at-least-once: in a crash between storing and committing the offset, the record may arrive twice — the destination must tolerate duplicates, as in any Kafka integration.

An Avro record that does not decode (missing schema, a value that is not Avro) raises an alert and is skipped: it stays in the topic, and reading of the others goes on.

Delivery — KAFKA_PRODUCE

FieldWhat it is for
Topic PublicationTopic name, with {{alias}} if you wish (cms.{{plant}}.readings). The magnifier lists the cluster’s topics
Record keyDecides the partition: same key, same partition and guaranteed order among them. For events of a piece of equipment, use its id ({{equipment}}). Empty = no key
Headers (JSON)Object {"name": "value"}; the value accepts {{alias}}. A header whose value resolves empty is omitted
Acknowledgment (acks)All replicas (all) (default, turns on the idempotent producer: no duplicates on a network retry), Leader only (1) (faster; may lose the message if the leader fails) or None (0)
CompressionNone, gzip, snappy, lz4 or zstd
Value formatText publishes the payload as is. Avro encodes the payload (JSON) with the latest version of the subject’s schema
Schema subjectAvro only. Empty = <topic>-value, the Confluent default. The magnifier lists the Schema Registry subjects

CMS does not create topics nor register schemas. A nonexistent topic is a delivery error, and the subject must be registered by the data team. In Avro, a payload field that does not match the schema is rejected before publishing, with the list of the fields.

What resolves against the input payload

Topic, key and headers resolve {{alias}} against the input payload, before the Transformer. Only the published body is the transformed one. A field created by the Transformer comes out empty in these fields — and an empty placeholder in the topic or the key is an error, not a publication to a ghost topic.

The screen shows this hint under the fields and warns, in amber, when an alias is not among the Input Parameters. The {} picker lists the input fields. It is the same rule as the dynamic MQTT topic and the routing key of RabbitMQ.

Common errors

MessageLikely cause
“The cluster answered on bootstrap but advertised the address …”advertised.listeners points to a name CMS cannot reach
“Kafka rejected the credentials”Wrong user, password or SASL mechanism. On Confluent Cloud, the key and secret must be the cluster’s
“Could not connect to Kafka”Bootstrap, port, security protocol or firewall
“The Kafka TLS certificate was not validated”Internal CA: paste it into CA certificate
“Topic … does not exist in the cluster”CMS does not create topics — ask the cluster administrator
“The connection user has no permission (ACL) on topic/group …”Missing read or write ACL on the topic, or read on the group
“Kafka record key with an empty value in …”The key alias is not in the input payload (before the Transformer) nor a Variable
“The message exceeds the maximum size accepted by the cluster/topic”Broker or topic message.max.bytes smaller than the payload
“Consumer group … is already used by collection …”Another CMS Collection already reads with that group on the same cluster
“Subject … does not exist in the Schema Registry”Schema not registered yet, or the subject has another name
“The Schema Registry rejected the credentials”On Confluent Cloud, the Schema Registry key is different from the cluster’s
“The content does not match the Avro schema of subject …”The Transformer produced fields the schema does not accept
“Record … is not in the Schema Registry Avro format”The Collection is on Avro, but the topic holds text — check the Value format

Testing in the Test Bench

In the Test Bench, the Publish to source mode publishes the payload to the Collection’s topic (the first one, if it reads several) and lets the Collection react through the normal path. The screen suggests as payload what the Collection has actually received. With the Collection on Avro, the stimulus is encoded with the schema before publishing.