【问题标题】:SpringXD receive MQTT and publish to MQTT on different topicSpringXD 接收 MQTT 并发布到不同主题的 MQTT
【发布时间】:2015-10-28 09:51:21
【问题描述】:

我目前正在开发我的第一个 SpringXD Stream。它应该接收关于 MQTT 主题的消息,对服务执行 HTTP POST 并将此结果发布到另一个 MQTT 主题。

目前,我坚持发布到与最初主题不同的 MQTT 主题。

这是我的直播:

stream create test --definition "in:mqtt --url='tcp://hivemq:1883' --topics='+/+/+/my/downlink' --username='test' --password='test' --clientId='client_downlink' 
| header-enricher --headers={\"mqtt_topic\":\"headers['mqtt_topic'].replace('/downlink', '/uplink')\"} 
| out:mqtt --url='tcp://hivemq:1883' --username='test' --password='test' --clientId='client_uplink'" --deploy

方法是在 Publishing 标头“mqtt_topic”中将“/downlink”替换为“/uplink”,但 header-enricher 不会覆盖现有的标头值,因此发布与我们收到的主题相同消息。

有什么办法可以做到这一点吗?

【问题讨论】:

    标签: spring-integration mqtt spring-xd


    【解决方案1】:

    我正在为此进行改进。同时,您可以编辑 header-enricher groovy 脚本modules/processor/header-enricher/config/header-enricher.groovy 并进行此更改:

    si.'header'(name:k,expression:v,overwrite:true)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-05-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-10-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多