title: spring integration kafka outbound adapter producer channel update metadata
body: <pre class="lang-xml prettyprint-override"><code>    &lt;int-kafka:outbound-channel-adapter sync="false" 
          kafka-template="kafkaTemplate" id="kafkaOutboundChannelAdapter" 
          topic="learning-topic" channel="KafkaAdapterChan" 
          send-failure-channel="FailureChan"&gt;
      &lt;/int-kafka:outbound-channel-adapter&gt;
  
      &lt;bean id="kafkaTemplate" class="org.springframework.kafka.core.KafkaTemplate"&gt;
          &lt;constructor-arg&gt;
              &lt;bean class="org.springframework.kafka.core.DefaultKafkaProducerFactory"&gt;
                  &lt;constructor-arg&gt;
                      &lt;map&gt;
                          &lt;entry key="bootstrap.servers" value="xyz:9092" /&gt;
                          ... &lt;!-- more producer properties --&gt;
                      &lt;/map&gt;
                  &lt;/constructor-arg&gt;
              &lt;/bean&gt;
          &lt;/constructor-arg&gt;
      &lt;/bean&gt;
  </code></pre>
  
  <p>Above sample works fine for happy path. But when the kafka cluster is restarted, i see the first message after the restart fails with an error "not a leader"...requesting to update metadata.</p>
  
  <p>Once the metadata got updated for the first message after restart, later messages are published correctly. So i am looking for if there is any way i can reinstantiate or update metadata for the kakfa producer outbound channel adapter when there is a kafka cluster restart?</p>