Spring integration SpringXD接收MQTT并发布到不同主题的MQTT

Spring integration SpringXD接收MQTT并发布到不同主题的MQTT,spring-integration,mqtt,spring-xd,Spring Integration,Mqtt,Spring Xd,我目前正在开发我的第一个SpringXD流。它应该接收有关MQTT主题的消息,在服务上执行HTTP POST,并在另一个MQTT主题上发布此结果 目前,我一直致力于发布到与初始主题不同的MQTT主题 这是我的流: stream create test --definition "in:mqtt --url='tcp://hivemq:1883' --topics='+/+/+/my/downlink' --username='test' --password='test' --clientId=

我目前正在开发我的第一个SpringXD流。它应该接收有关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
该方法是将用于发布的标题“mqtt_topic”中的“/downlink”替换为“/uplink”,但标题enricher不会覆盖现有的标题值,因此发布是在我们收到消息的同一主题上进行的


你知道我怎样才能做到这一点吗?

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

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