iotagent-mosca configuration is pretty simple. These are the environment variables used by it:

  • BACKEND_HOST, BACKEND_PORT: redis host and port to be used.

Receiving messages from DeviceManager via Kafka

Messages containing device operations should be in this format:

  "event": "create",
  "meta": {
    "service": "admin"
  "data": {
    "id": "cafe",
    "attrs" : {


These messages are related to device creation, update, removal and actuation. For creation and update operations, it contains the device data model to be added or updated. For removal operation, it will contain only the device ID being removed. The actuation operation will contain all attributes previously created with their respective values.

The documentation related to this message can be found in DeviceManager Messages.

Device configuration for iotagent-mosca

The following device attributes are considered by iotagent-mosca. All these attributes are of meta type.

Table 1 Device attributes for iotagent-mosca
Attribute Description Example
topic Topic to which the device will publish messages. /admin/efac/attrs


The following message serves as an example of a device with all attributes used by iotagent-mosca.

  "label": "Thermometer Template",
  "attrs": [
      "label": "topic",
      "type": "meta",
      "value_type": "string",
      "static_value": "/agent/main/000BABC80F4A/devinfo"
      "label": "temperature",
      "type": "dynamic",
      "value_type": "float"
      "label": "reset",
      "type": "actuator",
      "value_type": "boolean"

Sending messages to other components via Kafka

When iotagent-mosca receives a new message from a particular device, it must publish the new data to other components. The default subject used to publish this information is “device-data”. Check data-broker documentation to check how these subjects are translated into Kafka topics.

The message sent by iotagent-mosca is like this one:

    "metadata": {
        "deviceid": "c6ea4b",
        "tenant": "admin",
        "timestamp": 1528226137452
    "attrs": {
        "humidity": 60

Receiving messages from devices via MQTT

Any message payload sent to iotagent-mosca must be in JSON format. Preferably, they should follow a simple key-value structure, such as:

  "speed": 100.0,
  "weight": 50.2,
  "id": "truck-001"

If more than one device is supposed to use the same topic, you should set the client ID in all messages sent by devices. Its value should be service:ID, such as admin:efac.

Should the device send its messages using any other JSON scheme, the user could translate them into simple key-value structures using flows, using flowbuilder for that.


This example uses mosquitto_pub tool, available with mosquitto_clients package. To send a message to iotagent-mosca via MQTT, just execute this command:

mosquitto_pub -h localhost -i "admin:efac" -t /device/data -m '{"temperature" : 10}'

This command will send the message containing one value for attribute speed. The device ID is efac and its service is “admin”. -t flag sets the topic to which this message will be published and -i sets the client ID to be sent.

This command assumes that you are running iotagent-mosca in your machine (it also works if you use dojot’s docker-compose).