2014-10-01 77 views
2

使用Mule和MQTT我無法訂閱多個主題的客戶端。Mule ESB和MQTT連接器:訂閱多個主題

我配置配置全局元素以這樣的方式

<mqtt:config name="mqttSubscriber" doc:name="MQTT" brokerServerUri="${mqtt.url}" clientId="#['[email protected]'+server.host]" password="${mqtt.username}" username="${mqtt.password}"> 
    <mqtt:connection-pooling-profile initialisationPolicy="INITIALISE_ONE" exhaustedAction="WHEN_EXHAUSTED_WAIT" maxActive="1" maxIdle="1" maxWait="1"/> 
</mqtt:config> 

在流量使用:

<mqtt:subscribe config-ref="mqttSubscriber" doc:name="MQTTSubscriber1" topicFilter="a" qos="ONLY_ONCE"/> 

而在另一個流:

<mqtt:subscribe config-ref="mqttSubscriber" doc:name="MQTTSubscriber2" topicFilter="b" qos="ONLY_ONCE"/> 

應用程序啓動時,它只訂閱了一個主題。

我的配置有什麼問題?也許我必須創建不同的客戶端?

非常感謝。

回答

1

事實上,只有一個mqtt:subscribemqtt:config被允許,所以你需要:

  • 創建第二個mqtt:config和第二mqtt:subscribe
  • 使用它創建一個single multi-filter subscription並使用choice消息處理器路線消息基於mqtt.topicName入站消息屬性的值。

後者會更好IMO,因爲您只有一個活動連接,並且它利用MQTT的能力一次訂閱多個主題。