这是我希望的MQTT消息驱动的通道适配器的一个片段。
我想要的是让"主题"属性获取 presenceTopic 的值。
我应该将"topics"属性设置为什么才能让它使用"presenceTopic"作为引用而不是值?
<util:constant id="presenceTopic" static-field="blah blah"/>
<int-mqtt:message-driven-channel-adapter id="mqttInbound"
channel="inChannel"
client-id="blah blah"
url="${MQTT_URL}"
topics="__??__"
client-factory="clientFactory"/>
你需要学习 Spring 表达式语言和 Spring 功能,以便在 bean 初始化期间使用它:
topics="#{presenceTopic}"
这真的是对豆子的引用。
更多信息请参阅参考手册:
https://docs.spring.io/spring/docs/5.0.7.RELEASE/spring-framework-reference/core.html#expressions