Skip to main content

Apache Kafka

The gateway connects outbound as a client to topics on an external data streaming platform (Apache Kafka / Confluent Cloud / AWS MSK / Azure Event Hubs Kafka API) and performs consumer subscribe / producer send. Arriving records are stored in an in-memory cache, and the cached value is read at each tag's collection interval.

SituationWhich mode to use
An external IT system sends values via REST POSTHTTP Push
An external server pushes over WebSocketWebSocket Client
An external IIoT MQTT broker pushes on a topicMQTT Client
Receiving a Kafka topic as a consumerApache Kafka (this page)
Reading values directly from an in-house PLCModbus / OPC-UA, etc.

Registration form fields

FieldWhat to enterExample
IP addressKafka broker host (bootstrap)kafka.example.com, 10.0.0.50
PortBroker port (plaintext 9092, TLS 9093)9092, 9093
GROUP IDConsumer group id (optional)plant-floor-A, edge-line1
SECURITYSecurity protocolPLAINTEXT / SSL / SASL_PLAINTEXT / SASL_SSL
SASL MECHSASL mechanism (optional)PLAIN / SCRAM-SHA-256 / SCRAM-SHA-512
SASL JAASSASL authentication JAAS configuration (optional)org.apache.kafka.common.security.plain.PlainLoginModule required username="u" password="p";
AUTO OFFSETStarting point for a new grouplatest (default) / earliest
Collection intervalInterval at which the gateway reads the cached value (ms)1000

Actual broker URL: <host>:<port> (e.g. kafka.example.com:9092). Even if you register only one bootstrap host, the broker will advertise the rest of the cluster information for you.

If GROUP ID is not specified, it is generated automatically in the form plantpulse-edge-<opc_id>.


Tag PLC address notation — 4-mode JSON

A tag's PLC address = Kafka topic + 4-mode decoder. The spec is identical to MQTT / WebSocket.

ModeFormatBehavior
SCALARsensors/temp or sensors/temp.valueThe entire message as a String. If the message is a JSON object, falls back to raw.
KEYsensors/temp:temperatureValue of a top-level JSON key (e.g. {"temperature":25.3,"humidity":60}25.3)
PATHsensors/temp:$.data.tags.T1Dynamic JSON Pointer evaluation (nested keys supported)
RAWsensors/temp:_raw_The entire value of the last record (for debugging)

The first read call performs a lazy subscribe (returns an empty string). Cached values arrive from the next polling cycle onward.


Common use cases

CaseHow
In-house Kafka clusterhost = bootstrap broker IP, 9092 (plaintext)
Confluent Cloudhost = pkc-XXX.region.aws.confluent.cloud, 9092 + SASL_SSL + PLAIN mechanism + API key/secret JAAS
AWS MSK (IAM auth)host = b-1.<cluster>...amazonaws.com, 9098, IAM auth (separate JAAS configuration required)
Azure Event Hubs (Kafka API)host = <ns>.servicebus.windows.net, 9093 + SASL_SSL + PLAIN + Connection String JAAS
New consumer group + earliestSelect AUTO OFFSET=earliest to receive all existing data
Separating group offset managementRegister with a different GROUP ID — offsets are managed per group even for the same topic

write (producer.send)

When you write a value from the tag page or through the REST API, the producer sends it as a record to the corresponding topic (async, fire-and-forget). The String value is sent as the record value — JSON or plain text both work.

plc_address = factory/line1/cmd
value = ON
→ Kafka producer.send: topic="factory/line1/cmd" value="ON"
plc_address = factory/line1/cmd:temperature
value = 25.3
→ Kafka producer.send: topic="factory/line1/cmd" value="25.3" (콜론 뒤는 read decoder 정보, write 는 topic 만 사용)

Common problems and solutions

SymptomCauseSolution
No values arrivingThe broker is not sending recordsVerify by consuming directly with kafka-console-consumer.sh --bootstrap-server <host>:9092 --topic <t> --from-beginning
[KAFKA] connect 실패: TimeoutExceptionBootstrap server unreachableVerify telnet <host> 9092. Check whether advertised.listeners points to the external IP (broker side)
[KAFKA] poll error: Authentication failedSASL authentication failureRecheck sasl-mechanism / sasl-jaas-config. Escape special characters in the password
[KAFKA] poll error: SslHandshakeTLS truststore missing / expiredIssue the broker certificate from a trusted CA, or add it to the system truststore
New group receives no dataauto-offset=latest is set but there are no new recordsTemporarily change to earliest, or wait until a publish occurs

More detailed technical documentation