EdgexGo2.0学习-14 EdgeX2.0 AppService导出到Mqtt

导出到mqtt有几种方式:
(一)直接修改配置文件

  app-service-mqtt:
    container_name: edgex-app-mqtt
    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: mqtt-export
      EDGEX_SECURITY_SECRET_STORE: "false"
      MESSAGEQUEUE_HOST: edgex-redis
      REGISTRY_HOST: edgex-core-consul
      SERVICE_HOST: edgex-app-mqtt
      TRIGGER_EDGEXMESSAGEBUS_PUBLISHHOST_HOST: edgex-redis
      TRIGGER_EDGEXMESSAGEBUS_SUBSCRIBEHOST_HOST: edgex-redis
      WRITABLE_PIPELINE_FUNCTIONS_MQTTEXPORT_PARAMETERS_BROKERADDRESS: tcp://192.168.10.39:1883
      WRITABLE_PIPELINE_FUNCTIONS_MQTTEXPORT_PARAMETERS_TOPIC: EdgeXEvents  # 可以修改主题
    hostname: edgex-app-mqtt
    image: edgexfoundry/app-service-configurable:2.0.0
    networks:
      demo: {}
    ports:
    - 127.0.0.1:59702:59702/tcp
    read_only: true
    security_opt:
    - no-new-privileges:true
    user: 2002:2001    

(二)开发一个应用。
1、复制xx-xml-mqtt重命名为xx-json-mqtt
image
2、修改TransformToXML为TransFormToJson
image
3、修改配置文件,ip地址为自己的ip地址
image
4、启动app
~/appservice/simple-filter-json-mqtt# ./app-service

最终接收到订阅消息如下
image
(三)直接在GoUI上设置AppService方式有问题,但在1.2下是可以的,

posted @ 2021-10-27 16:26  zhaogaojian  阅读(230)  评论(0编辑  收藏  举报