Serialization

The Kafka connector acts as a “pass-through” connector. Key and message data is not transformed. Messages sent to a Kafka connector topic should be serialized JSON messages of the same type specified in the model (.NET Core, Java, Rules Based).

For example, if a digital twin model has a message implementation containing the following properties: “myMessageType”, “myStringStateChange”, “myIntegerStateChange”, and “timestamp” – using the kafka-console-producer.sh convenience script, you can send a message to a digital twin instance with the following code:

    $ bin/kafka-console-producer.sh --bootstrap-server localhost:9092 --topic MyDigitalTwinTopic --property "parse.key=true" --property "key.separator=|"
Instance_23|{"myMessageType":"initialMessage", "myStringStateChange":"initialMessage", "myIntegerStateChange":10, "timestamp":1561273200000}

Note

The Kafka connector requires messages within Kafka to specify a key. The key will be used as the instance identifier for the corresponding real-time digital twin instance.