This article, the fifth in the Edgex series, will show you how to export previously connected device data to our MQTT or HTTP device for use.

Export the data to the MQTT service

Again, go to the Edgex-compose project and click on the compose Builder and drag the scroll bar to Pull

We can customize the composition of the required services according to the selection, MQTT export services here, we select ASC-MQTT

I’m going to go in the same way as beforecompose-builderDirectory to performmake asc-mqtt no-secty, we copy the contents of ASC-MQTT to our previous onedocker-compose.ymlThe final file is as follows:

networks:
  edgex-network:
    driver: bridge
services:
  app-service-mqtt-export:
    container_name: edgex-app-mqtt-export
    depends_on:
    - consul
    - data
    environment:
      CLIENTS_CORE_COMMAND_HOST: edgex-core-command
      CLIENTS_CORE_DATA_HOST: edgex-core-data
      CLIENTS_CORE_METADATA_HOST: edgex-core-metadata
      CLIENTS_SUPPORT_NOTIFICATIONS_HOST: edgex-support-notifications
      CLIENTS_SUPPORT_SCHEDULER_HOST: edgex-support-scheduler
      DATABASES_PRIMARY_HOST: edgex-redis
      DATABASE_HOST: edgex-redis
      EDGEX_PROFILE: mqtt-export
      EDGEX_SECURITY_SECRET_STORE: "false"
      MESSAGEQUEUE_HOST: edgex-redis
      REGISTRY_HOST: edgex-core-consul
      SERVICE_HOST: edgex-app-mqtt-export
      TRIGGER_EDGEXMESSAGEBUS_PUBLISHHOST_HOST: edgex-redis
      TRIGGER_EDGEXMESSAGEBUS_SUBSCRIBEHOST_HOST: edgex-redis
      WRITABLE_LOGLEVEL: INFO
      WRITABLE_PIPELINE_FUNCTIONS_MQTTEXPORT_PARAMETERS_BROKERADDRESS: tcp://broker.mqttdashboard.com:1883
      WRITABLE_PIPELINE_FUNCTIONS_MQTTEXPORT_PARAMETERS_TOPIC: edgex-events
    hostname: edgex-app-mqtt-export
    image: edgexfoundry/app-service-configurable:2.0.1
    networks:
      edgex-network: null
    ports:
    - 59703:59703/tcp
    read_only: true
    security_opt:
    - no-new-privileges:true
    user: 2002:2001
  app-service-rules:
    container_name: edgex-app-rules-engine
    depends_on:
    - consul
    - data
    environment:
      CLIENTS_CORE_COMMAND_HOST: edgex-core-command
      CLIENTS_CORE_DATA_HOST: edgex-core-data
      CLIENTS_CORE_METADATA_HOST: edgex-core-metadata
      CLIENTS_SUPPORT_NOTIFICATIONS_HOST: edgex-support-notifications
      CLIENTS_SUPPORT_SCHEDULER_HOST: edgex-support-scheduler
      DATABASES_PRIMARY_HOST: edgex-redis
      EDGEX_PROFILE: rules-engine
      EDGEX_SECURITY_SECRET_STORE: "false"
      MESSAGEQUEUE_HOST: edgex-redis
      REGISTRY_HOST: edgex-core-consul
      SERVICE_HOST: edgex-app-rules-engine
      TRIGGER_EDGEXMESSAGEBUS_PUBLISHHOST_HOST: edgex-redis
      TRIGGER_EDGEXMESSAGEBUS_SUBSCRIBEHOST_HOST: edgex-redis
    hostname: edgex-app-rules-engine
    image: edgexfoundry/app-service-configurable:2.0.1
    networks:
      edgex-network: null
    ports:
    - 59701:59701/tcp
    read_only: true
    security_opt:
    - no-new-privileges:true
    user: 2002:2001
  command:
    container_name: edgex-core-command
    depends_on:
    - consul
    - database
    - metadata
    environment:
      CLIENTS_CORE_COMMAND_HOST: edgex-core-command
      CLIENTS_CORE_DATA_HOST: edgex-core-data
      CLIENTS_CORE_METADATA_HOST: edgex-core-metadata
      CLIENTS_SUPPORT_NOTIFICATIONS_HOST: edgex-support-notifications
      CLIENTS_SUPPORT_SCHEDULER_HOST: edgex-support-scheduler
      DATABASES_PRIMARY_HOST: edgex-redis
      EDGEX_SECURITY_SECRET_STORE: "false"
      MESSAGEQUEUE_HOST: edgex-redis
      REGISTRY_HOST: edgex-core-consul
      SERVICE_HOST: edgex-core-command
    hostname: edgex-core-command
    image: edgexfoundry/core-command:2.0.0
    networks:
      edgex-network: null
    ports:
    - 59882:59882/tcp
    read_only: true
    security_opt:
    - no-new-privileges:true
    user: 2002:2001
  consul:
    container_name: edgex-core-consul
    hostname: edgex-core-consul
    image: consul:1.9.5
    networks:
      edgex-network: null
    ports:
    - 8500:8500/tcp
    read_only: true
    security_opt:
    - no-new-privileges:true
    user: root:root
    volumes:
    - consul-config:/consul/config:z
    - consul-data:/consul/data:z
  data:
    container_name: edgex-core-data
    depends_on:
    - consul
    - database
    - metadata
    environment:
      CLIENTS_CORE_COMMAND_HOST: edgex-core-command
      CLIENTS_CORE_DATA_HOST: edgex-core-data
      CLIENTS_CORE_METADATA_HOST: edgex-core-metadata
      CLIENTS_SUPPORT_NOTIFICATIONS_HOST: edgex-support-notifications
      CLIENTS_SUPPORT_SCHEDULER_HOST: edgex-support-scheduler
      DATABASES_PRIMARY_HOST: edgex-redis
      EDGEX_SECURITY_SECRET_STORE: "false"
      MESSAGEQUEUE_HOST: edgex-redis
      REGISTRY_HOST: edgex-core-consul
      SERVICE_HOST: edgex-core-data
    hostname: edgex-core-data
    image: edgexfoundry/core-data:2.0.0
    networks:
      edgex-network: null
    ports:
    - 5563:5563/tcp
    - 59880:59880/tcp
    read_only: true
    security_opt:
    - no-new-privileges:true
    user: 2002:2001
  database:
    container_name: edgex-redis
    environment:
      CLIENTS_CORE_COMMAND_HOST: edgex-core-command
      CLIENTS_CORE_DATA_HOST: edgex-core-data
      CLIENTS_CORE_METADATA_HOST: edgex-core-metadata
      CLIENTS_SUPPORT_NOTIFICATIONS_HOST: edgex-support-notifications
      CLIENTS_SUPPORT_SCHEDULER_HOST: edgex-support-scheduler
      DATABASES_PRIMARY_HOST: edgex-redis
      EDGEX_SECURITY_SECRET_STORE: "false"
      MESSAGEQUEUE_HOST: edgex-redis
      REGISTRY_HOST: edgex-core-consul
    hostname: edgex-redis
    image: redis:6.2.4-alpine
    networks:
      edgex-network: null
    ports:
    - 6379:6379/tcp
    read_only: true
    security_opt:
    - no-new-privileges:true
    user: root:root
    volumes:
    - db-data:/data:z
  device-mqtt:
    container_name: edgex-device-mqtt
    depends_on:
    - consul
    - data
    - metadata
    - mqtt-broker
    environment:
      CLIENTS_CORE_COMMAND_HOST: edgex-core-command
      CLIENTS_CORE_DATA_HOST: edgex-core-data
      CLIENTS_CORE_METADATA_HOST: edgex-core-metadata
      CLIENTS_SUPPORT_NOTIFICATIONS_HOST: edgex-support-notifications
      CLIENTS_SUPPORT_SCHEDULER_HOST: edgex-support-scheduler
      DATABASES_PRIMARY_HOST: edgex-redis
      EDGEX_SECURITY_SECRET_STORE: "false"
      MESSAGEQUEUE_HOST: edgex-redis
      MQTTBROKERINFO_HOST: edgex-mqtt-broker
      REGISTRY_HOST: edgex-core-consul
      SERVICE_HOST: edgex-device-mqtt
      DEVICE_DEVICESDIR: /custom-config/devices
      DEVICE_PROFILESDIR: /custom-config/profiles
    hostname: edgex-device-mqtt
    image: edgexfoundry/device-mqtt:2.0.0
    networks:
      edgex-network: null
    ports:
    - 59982:59982/tcp
    read_only: true
    security_opt:
    - no-new-privileges:true
    user: 2002:2001
    volumes:
    - /usr/local/cq/tool/custom-config:/custom-config
  metadata:
    container_name: edgex-core-metadata
    depends_on:
    - consul
    - database
    - notifications
    environment:
      CLIENTS_CORE_COMMAND_HOST: edgex-core-command
      CLIENTS_CORE_DATA_HOST: edgex-core-data
      CLIENTS_CORE_METADATA_HOST: edgex-core-metadata
      CLIENTS_SUPPORT_NOTIFICATIONS_HOST: edgex-support-notifications
      CLIENTS_SUPPORT_SCHEDULER_HOST: edgex-support-scheduler
      DATABASES_PRIMARY_HOST: edgex-redis
      EDGEX_SECURITY_SECRET_STORE: "false"
      MESSAGEQUEUE_HOST: edgex-redis
      NOTIFICATIONS_SENDER: edgex-core-metadata
      REGISTRY_HOST: edgex-core-consul
      SERVICE_HOST: edgex-core-metadata
    hostname: edgex-core-metadata
    image: edgexfoundry/core-metadata:2.0.0
    networks:
      edgex-network: null
    ports:
    - 59881:59881/tcp
    read_only: true
    security_opt:
    - no-new-privileges:true
    user: 2002:2001
  mqtt-broker:
    command: /usr/sbin/mosquitto -c /mosquitto-no-auth.conf
    container_name: edgex-mqtt-broker
    hostname: edgex-mqtt-broker
    image: eclipse-mosquitto:2.0.11
    networks:
      edgex-network: null
    ports:
    - published: 1883
      target: 1883
    read_only: true
    security_opt:
    - no-new-privileges:true
    user: 2002:2001
  notifications:
    container_name: edgex-support-notifications
    depends_on:
    - consul
    - database
    environment:
      CLIENTS_CORE_COMMAND_HOST: edgex-core-command
      CLIENTS_CORE_DATA_HOST: edgex-core-data
      CLIENTS_CORE_METADATA_HOST: edgex-core-metadata
      CLIENTS_SUPPORT_NOTIFICATIONS_HOST: edgex-support-notifications
      CLIENTS_SUPPORT_SCHEDULER_HOST: edgex-support-scheduler
      DATABASES_PRIMARY_HOST: edgex-redis
      EDGEX_SECURITY_SECRET_STORE: "false"
      MESSAGEQUEUE_HOST: edgex-redis
      REGISTRY_HOST: edgex-core-consul
      SERVICE_HOST: edgex-support-notifications
    hostname: edgex-support-notifications
    image: edgexfoundry/support-notifications:2.0.0
    networks:
      edgex-network: null
    ports:
    - 59860:59860/tcp
    read_only: true
    security_opt:
    - no-new-privileges:true
    user: 2002:2001
  rulesengine:
    container_name: edgex-kuiper
    depends_on:
    - database
    environment:
      EDGEX__DEFAULT__PORT: 6379
      EDGEX__DEFAULT__PROTOCOL: redis
      EDGEX__DEFAULT__SERVER: edgex-redis
      EDGEX__DEFAULT__TOPIC: rules-events
      EDGEX__DEFAULT__TYPE: redis
      KUIPER__BASIC__CONSOLELOG: "true"
      KUIPER__BASIC__RESTPORT: 59720
    hostname: edgex-kuiper
    image: lfedge/ekuiper:1.3.0-alpine
    networks:
      edgex-network: null
    ports:
    - 59720:59720/tcp
    read_only: true
    security_opt:
    - no-new-privileges:true
    user: kuiper:kuiper
    volumes:
    - kuiper-data:/kuiper/data:z
  scheduler:
    container_name: edgex-support-scheduler
    depends_on:
    - consul
    - database
    environment:
      CLIENTS_CORE_COMMAND_HOST: edgex-core-command
      CLIENTS_CORE_DATA_HOST: edgex-core-data
      CLIENTS_CORE_METADATA_HOST: edgex-core-metadata
      CLIENTS_SUPPORT_NOTIFICATIONS_HOST: edgex-support-notifications
      CLIENTS_SUPPORT_SCHEDULER_HOST: edgex-support-scheduler
      DATABASES_PRIMARY_HOST: edgex-redis
      EDGEX_SECURITY_SECRET_STORE: "false"
      INTERVALACTIONS_SCRUBAGED_HOST: edgex-core-data
      INTERVALACTIONS_SCRUBPUSHED_HOST: edgex-core-data
      MESSAGEQUEUE_HOST: edgex-redis
      REGISTRY_HOST: edgex-core-consul
      SERVICE_HOST: edgex-support-scheduler
    hostname: edgex-support-scheduler
    image: edgexfoundry/support-scheduler:2.0.0
    networks:
      edgex-network: null
    ports:
    - 59861:59861/tcp
    read_only: true
    security_opt:
    - no-new-privileges:true
    user: 2002:2001
  system:
    container_name: edgex-sys-mgmt-agent
    depends_on:
    - command
    - consul
    - data
    - metadata
    - notifications
    - scheduler
    environment:
      CLIENTS_CORE_COMMAND_HOST: edgex-core-command
      CLIENTS_CORE_DATA_HOST: edgex-core-data
      CLIENTS_CORE_METADATA_HOST: edgex-core-metadata
      CLIENTS_SUPPORT_NOTIFICATIONS_HOST: edgex-support-notifications
      CLIENTS_SUPPORT_SCHEDULER_HOST: edgex-support-scheduler
      DATABASES_PRIMARY_HOST: edgex-redis
      EDGEX_SECURITY_SECRET_STORE: "false"
      EXECUTORPATH: /sys-mgmt-executor
      MESSAGEQUEUE_HOST: edgex-redis
      METRICSMECHANISM: executor
      REGISTRY_HOST: edgex-core-consul
      SERVICE_HOST: edgex-sys-mgmt-agent
    hostname: edgex-sys-mgmt-agent
    image: edgexfoundry/sys-mgmt-agent:2.0.0
    networks:
      edgex-network: null
    ports:
    - 58890:58890/tcp
    read_only: true
    security_opt:
    - label:disable
    - no-new-privileges:true
    user: root:root
    volumes:
    - /var/run/docker.sock:/var/run/docker.sock:z
  ui:
    container_name: edgex-ui-go
    hostname: edgex-ui-go
    image: edgexfoundry/edgex-ui:2.0.0
    networks:
      edgex-network: null
    ports:
    - 4000:4000/tcp
    read_only: true
    security_opt:
    - no-new-privileges:true
    user: 2002:2001
  device-virtual:
   container_name: edgex-device-virtual
   depends_on:
   - consul
   - data
   - metadata
   environment:
     CLIENTS_CORE_COMMAND_HOST: edgex-core-command
     CLIENTS_CORE_DATA_HOST: edgex-core-data
     CLIENTS_CORE_METADATA_HOST: edgex-core-metadata
     CLIENTS_SUPPORT_NOTIFICATIONS_HOST: edgex-support-notifications
     CLIENTS_SUPPORT_SCHEDULER_HOST: edgex-support-scheduler
     DATABASES_PRIMARY_HOST: edgex-redis
     EDGEX_SECURITY_SECRET_STORE: "false"
     MESSAGEQUEUE_HOST: edgex-redis
     REGISTRY_HOST: edgex-core-consul
     SERVICE_HOST: edgex-device-virtual
   hostname: edgex-device-virtual
   image: edgexfoundry/device-virtual:2.0.0
   networks:
     edgex-network: {}
   ports:
   - 59900:59900/tcp
   read_only: true
   security_opt:
   - no-new-privileges:true
   user: 2002:2001
version: '3.7'
volumes:
  consul-config: {}
  consul-data: {}
  db-data: {}
  kuiper-data: {}

Copy the code

We separate out the configuration of the MQTT export service as follows:

app-service-mqtt-export: container_name: edgex-app-mqtt-export depends_on: - consul - data environment: CLIENTS_CORE_COMMAND_HOST: edgex-core-command CLIENTS_CORE_DATA_HOST: edgex-core-data CLIENTS_CORE_METADATA_HOST: edgex-core-metadata CLIENTS_SUPPORT_NOTIFICATIONS_HOST: edgex-support-notifications CLIENTS_SUPPORT_SCHEDULER_HOST: edgex-support-scheduler DATABASES_PRIMARY_HOST: edgex-redis DATABASE_HOST: edgex-redis EDGEX_PROFILE: mqtt-export EDGEX_SECURITY_SECRET_STORE: "false" MESSAGEQUEUE_HOST: edgex-redis REGISTRY_HOST: edgex-core-consul SERVICE_HOST: edgex-app-mqtt-export TRIGGER_EDGEXMESSAGEBUS_PUBLISHHOST_HOST: edgex-redis TRIGGER_EDGEXMESSAGEBUS_SUBSCRIBEHOST_HOST: edgex-redis WRITABLE_LOGLEVEL: INFO WRITABLE_PIPELINE_FUNCTIONS_MQTTEXPORT_PARAMETERS_BROKERADDRESS: tcp://broker.mqttdashboard.com:1883 WRITABLE_PIPELINE_FUNCTIONS_MQTTEXPORT_PARAMETERS_TOPIC: edgex-events hostname: Edgex-app-mqtt-export Image: EdgexFoundry/app-service-signals :2.0.1 Networks: Edgex-network: NULL ports: Works without any additional control system. - 59703:59703/tcp read_only: true security_opt: - no-new-privileges:true user: 2002:2001Copy the code

WRITABLE_PIPELINE_FUNCTIONS_MQTTEXPORT_PARAMETERS_BROKERADDRESS Export address and WRITABLE_PIPELINE_FUNCTIONS_MQTTEXPORT_PARAMETERS_TO PIC export subject can be customized to facilitate service reception.

Next, we enter the Web client of MQTT for testing, output Host and Port, and then connect

Next we subscribe to the topic edgex-Events that we just configured

Data in, export successful.

Export data to HTTP service

Go to the compose builder directory and make THE ASC-HTTP no-secty. We copy the content of the ASC-HTTP to our previous docker-comemage. yml file and add it to the configuration file

. app-service-http-export: container_name: edgex-app-http-export depends_on: - consul - data environment: CLIENTS_CORE_COMMAND_HOST: edgex-core-command CLIENTS_CORE_DATA_HOST: edgex-core-data CLIENTS_CORE_METADATA_HOST: edgex-core-metadata CLIENTS_SUPPORT_NOTIFICATIONS_HOST: edgex-support-notifications CLIENTS_SUPPORT_SCHEDULER_HOST: edgex-support-scheduler DATABASES_PRIMARY_HOST: edgex-redis DATABASE_HOST: edgex-redis EDGEX_PROFILE: http-export EDGEX_SECURITY_SECRET_STORE: "false" MESSAGEQUEUE_HOST: edgex-redis REGISTRY_HOST: edgex-core-consul SERVICE_HOST: edgex-app-http-export TRIGGER_EDGEXMESSAGEBUS_PUBLISHHOST_HOST: edgex-redis TRIGGER_EDGEXMESSAGEBUS_SUBSCRIBEHOST_HOST: edgex-redis WRITABLE_LOGLEVEL: The INFO WRITABLE_PIPELINE_FUNCTIONS_HTTPEXPORT_PARAMETERS_URL: hostname: http://192.168.10.131:8080/income Edgex-app-http-export Image: Edgexfoundry/app-service-64x :2.0.1 Networks: Edgex-network: NULL ports: Works without any additional information. - 59704:59704/tcp read_only: true security_opt: - no-new-privileges:true user: 2002:2001 device-rest: container_name: edgex-device-rest depends_on: - consul - data - metadata environment: CLIENTS_CORE_COMMAND_HOST: edgex-core-command CLIENTS_CORE_DATA_HOST: edgex-core-data CLIENTS_CORE_METADATA_HOST: edgex-core-metadata CLIENTS_SUPPORT_NOTIFICATIONS_HOST: edgex-support-notifications CLIENTS_SUPPORT_SCHEDULER_HOST: edgex-support-scheduler DATABASES_PRIMARY_HOST: edgex-redis EDGEX_SECURITY_SECRET_STORE: "false" MESSAGEQUEUE_HOST: edgex-redis REGISTRY_HOST: edgex-core-consul SERVICE_HOST: edgex-device-rest hostname: edgex-device-rest image: Edgexfoundry/device - rest: 2.0.0 networks: edgex - network: null ports: - 127.0.0.1:59986-59986 / TCP read_only: true security_opt: - no-new-privileges:true user: 2002:2001 ...Copy the code

Note WRITABLE_PIPELINE_FUNCTIONS_HTTPEXPORT_PARAMETERS_URL: Our export endpoint is configured on http://192.168.10.131:8080/income here, that is, http://192.168.10.131:8080/income, this is one of my custom springboot applications

And then we executedocker-compose up -d, the use ofdocker psCheck whether the service is started. After the service is ok, start our SpringBoot application and you can see that data is constantly pushed to us

So far we have exported HTTP data successfully.

Other ways of data export

  1. useapp-function-goCustom export application services.
  2. useeKuiperData Export function

4. Recommended videos

The official meetup

5. Reference materials

Docs.edgexfoundry.org/2.0/walk-th… Github.com/edgexfoundr…