title: Not able to publish messages on rabbitmq to direct exchange using routing key with spring cloud
body: <p>I have a rabbitmq exchange [test-exchange] which is a direct exchange that is binded to queue [test-queue] using routing key [test-routing-key].</p>
  
  <p>I am trying to publish messages to this exchange using spring cloud stream but messages are not reaching the queue</p>
  
  <p>My dependency in pom.xml</p>
  
  <pre><code>&lt;dependency&gt;
      &lt;groupId&gt;org.springframework.cloud&lt;/groupId&gt;
      &lt;artifactId&gt;spring-cloud-starter-stream-rabbit&lt;/artifactId&gt;
  &lt;/dependency&gt;
  </code></pre>
  
  <p>Spring cloud used is Edgware.RELEASE</p>
  
  <p>My source file code is </p>
  
  <pre><code>public interface DemoSource {
  
      @Output("demoChannel")
      MessageChannel userChannel();
  
  }
  </code></pre>
  
  <p>My application file code is</p>
  
  <pre><code>@SpringBootApplication
  @EnableBinding(DemoSource.class)
  public class PublisherApplication implements CommandLineRunner{
  
      @Autowired
      DemoSource demoSource;
  
      public static void main(String[] args) {
          SpringApplication sp = new SpringApplication(PublisherApplication.class);
          sp.run(args);
  
      }
  
      @Override
      public void run(String... args) throws Exception {
          System.out.println("Sending message...");
          User user = new User();
          user.setUserId("testId");
          user.setUserName("testName");
          demoSource.userChannel().send(MessageBuilder.withPayload(user).build());
  
      }
  
  }
  
  </code></pre>
  
  <p>My application.properties file is</p>
  
  <pre><code>spring.rabbitmq.host=localhost
  spring.rabbitmq.port=5672
  spring.rabbitmq.username=guest
  spring.rabbitmq.password=guest
  
  spring.cloud.stream.bindings.demoChannel.destination=test-exchange
  spring.cloud.stream.bindings.demoChannel.group=test-routing-key
  spring.cloud.stream.bindings.demoChannel.producer.bindingRoutingKey=test-routing-key
  spring.cloud.stream.bindings.demoChannel.producer.routing-key-expression= 'test-routing-key'
  spring.cloud.stream.rabbit.bindings.demoChannel.producer.exchange-type=direct
  spring.cloud.stream.rabbit.bindings.demoChannel.producer.declare-exchange=false
  spring.cloud.stream.default.contentType=application/json
  
  </code></pre>