title: Not able to publish a message onto RabbitMQ using header exchange with Spring Boot
body: <p>I have a very basic <code>Spring Boot</code> application that is publishing two messages to <code>RabbitMQ</code> using <code>headers</code> exchange. Both the <code>exchange</code> and <code>queue</code> is getting created but the message is not reaching to the queue. I do not see any exception either.</p>
  
  <p>I googled around but could not find any examples related to this. </p>
  
  <p><strong>BasicApplication.java</strong></p>
  
  <pre><code>@SpringBootApplication
  public class BasicApplication {
  
      public static final String QUEUE_NAME = "helloworld.header.red.q";
      public static final String EXCHANGE_NAME = "helloworld.header.x";
  
      //here the message ==&gt; xchange ==&gt; queue1, queue2
      @Bean
      public List&lt;Object&gt; headerBindings() {
          Queue headerRedQueue = new Queue(QUEUE_NAME, false);
          HeadersExchange headersExchange = new HeadersExchange(EXCHANGE_NAME);
          return Arrays.asList(headerRedQueue, headersExchange,
                  bind(headerRedQueue).to(headersExchange).where("color").matches("red"));
      }
  
      public static void main(String[] args) {
          SpringApplication.run(BasicApplication.class, args).close();
      }
  
  }
  </code></pre>
  
  <p><strong>Producer.java</strong></p>
  
  <pre><code>@Component
  public class Producer implements CommandLineRunner {
  
      @Autowired
      private RabbitTemplate rabbitTemplate;
  
      @Override
      public void run(String... args) throws Exception {
          MessageProperties messageProperties = new MessageProperties();
  
          //send a message with "color: red" header in the queue, this will show up in the queue
          messageProperties.setHeader("color", "red");
          //MOST LIKELY THE PROBLEM IS HERE
          //BELOW MESSAGE IS NOT LINKED TO ABOVE messageProperties OBJECT
          this.rabbitTemplate.convertAndSend(EXCHANGE_NAME, "", "Hello World !");
  
          //send another message with "color: gold" header in the queue, this will NOT show up in the queue
          messageProperties.setHeader("color", "gold");
          this.rabbitTemplate.convertAndSend(EXCHANGE_NAME, "", "Hello World !");
      }
  
  }
  </code></pre>