Aniston NexusDocs
Open Aniston Nexus

Kafka

Use Apache Kafka as the internal platform queue or to publish selected data to other systems, with TLS and SASL in production.

Aniston Nexus uses Apache Kafka in two separate ways. Keep them apart: you can use either one without the other.

Internal platform queueOutbound publishing
WhatThe platform's own message queues (rule engine, core, transport)Rule chains send selected data to a Kafka topic for other systems
SettingTB_QUEUE_TYPE=kafka + TB_KAFKA_SERVERS (backend environment)The kafka rule node (bootstrap servers, topic, key)
Defaultin-memory: no broker; messages in flight are lost on restartOff; install the Kafka Telemetry Export rule chain
Change needsBackend restartSaving the rule chain
SecretsBackend environment / .env onlyStored in the rule node on the server

The browser never sees Kafka settings or credentials.

Run a broker

A single-node broker for development and small sites is in docker-local/docker-compose.kafka.yml (Apache Kafka 3.9.1, KRaft, data in the volume nexus_kafka-data, 7 days / 1 GB per partition retention):

docker compose -f docker-local/docker-compose.yml -f docker-local/docker-compose.kafka.yml up -d kafka
bash docker-local/kafka/kafka-check.sh

The check creates the topic nexus.healthcheck, produces a record and consumes it back; it prints Kafka check passed or the step that failed. Inside Docker the broker is kafka:9092; from the host, localhost:9094 (tests only, bound to 127.0.0.1).

Publish telemetry to Kafka

  1. Install Kafka Telemetry Export from the catalogue (IoT Hub > Rule chains), or import solutions/nexus-kafka/rule_chains/kafka_telemetry_export.json.
  2. In the Root Rule Chain, add a rule chain node pointing at it and connect Save Timeseries Success to it.
  3. Watch the topic: bash docker-local/kafka/kafka-check.sh --topic nexus.telemetry --consume-only.

Records: key = device name, value = the telemetry JSON, headers = message metadata (deviceName, deviceType, ts …). Failures go to the chain's log node.

Use Kafka as the internal queue

Set in docker-local/.env (production: deploy/production/.env) and restart the backend:

TB_QUEUE_TYPE=kafka
TB_KAFKA_SERVERS=kafka:9092

Start the stack with the Kafka overlay so the broker runs. The platform creates its topics (tb_core.*, tb_rule_engine.*, …) on first start. Keep the broker's volume: deleting it while the platform uses it loses queued messages.

TLS and SASL (production)

Internal queue, TLS: TB_KAFKA_SSL_ENABLED=true, TB_KAFKA_SSL_TRUSTSTORE_LOCATION, TB_KAFKA_SSL_TRUSTSTORE_PASSWORD (and the keystore variables for client certificates). SASL over TLS: TB_QUEUE_KAFKA_USE_CONFLUENT_CLOUD=true with TB_QUEUE_KAFKA_CONFLUENT_SECURITY_PROTOCOL=SASL_SSL, TB_QUEUE_KAFKA_CONFLUENT_SASL_MECHANISM (PLAIN, SCRAM-SHA-512) and TB_QUEUE_KAFKA_CONFLUENT_SASL_JAAS_CONFIG. Despite the name, this block works with any SASL_SSL broker.

Rule node: choose the Authentication type in the node:

TypeYou enterThe node sets
None (default; nodes saved before this option keep it)nothingno security settings; put security.protocol, sasl.* and ssl.* in Other properties yourself
SASL PLAIN, SCRAM-SHA-256, SCRAM-SHA-512security protocol, username, passwordsecurity.protocol, sasl.mechanism, sasl.jaas.config
SASL OAUTHBEARER (OAuth 2.0)security protocol, token endpoint URL, client ID, client secret, optional scopethe above plus sasl.login.callback.handler.class (the Kafka client's own OIDC handler) and sasl.oauthbearer.token.endpoint.url

With OAUTHBEARER the Kafka client fetches an access token from the identity provider (Keycloak, Azure AD / Entra ID, Okta …) with the client credentials grant and refreshes it before it expires; the broker validates it. The token endpoint must be an http:// or https:// URL (file URLs are refused). The security protocol is SASL_SSL (recommended) or SASL_PLAINTEXT (trusted networks only). The node's settings replace the same keys in Other properties; TLS trust settings for the broker (ssl.truststore.*) still go there.

If the JVM system property org.apache.kafka.sasl.oauthbearer.allowed.urls is set on the backend, the token endpoint URL must be in that comma-separated list, or the node fails to start with a message naming the property. With the bundled Kafka client (3.9) an unset property allows any URL; Kafka clients 4.0 and later allow none unless it is set.

The password and client secret are stored in the rule node configuration on the server (like other rule node credentials) and are not written to the logs.

All of these need a backend restart (internal queue) or a rule-chain save (rule node).