title: Spring Mqtt - Publish messages to multiple topics programmatically
body: <p>How can I publish messages with different topics programmatically?</p>
  
  <pre><code>&lt;mqtt:outbound-channel-adapter id="mqttOut" 
      auto-startup="true" 
      client-id="foo"
      url="tcp://localhost:1883"
      client-factory="clientFactory"
      default-qos="0"
      default-retained="false"
      default-topic="bar"
      async="true"
      async-events="true" /&gt;
  </code></pre>
  
  <p>I tried <a href="https://stackoverflow.com/questions/28313985/spring-integration-mqtt-publish-subscribe-to-multiple-topics">Spring integration MQTT publish &amp; subscribe to multiple topics</a>, but were not able to configure.</p>
  
  <p>Also tried with <code>MqttPahoMessageHandlerAdapter</code> which has a <code>publish()</code> but <code>protected</code>.</p>
  
  <p>Going with <code>org.eclipse.paho.client.mqttv3.MqttAsyncClient</code> and <code>org.eclipse.paho.client.mqttv3.MqttCallback</code> is very easy. But I would like to stick with spring all the way.</p>
  
  <p>Appreciate if somebody can points me to a correct direction.</p>