Q:

Spring cloud stream rabbitMQ consumer partition

I created a sample HttpSource and HttpSink. My application.properties looks like this
Source
spring.cloud.stream.bindings.output.destination=greetings
spring.cloud.stream.bindings.output.partitionKeyExpression=payload
spring.cloud.stream.bindings.output.partitionCount=2

Sink
spring.cloud.stream.bindings.input.destination=greetings
spring.cloud.stream.bindings.input.partitioned=true
spring.cloud.stream.instanceCount=2
spring.cloud.stream.instanceIndex=0

HttpSource
@RestController
@EnableBinding(Source.class)
 public class SampleSource {

 @Autowired
 private MessageChannel output;

 @RequestMapping(path="/message",method=RequestMethod.POST)
 public void sendMessage(@RequestBody String name){
    output.send(MessageBuilder.withPayload("Hello, "+name).build());
 }
}

HttpSink
@EnableBinding(Sink.class)
public class SampleSink {

 @ServiceActivator(inputChannel=Sink.INPUT)
 public void sendMessage(String name){
    System.out.println(name);
 }
}

I deployed both these apps to Pivotal Cloud Foundry. The HttpSource has an endpoint which on calling sends message to a Topic exchange called "greetings". Then I scaled the HttpSink to have 2 instances. This created two queues and bindings to "greetings" exchange.
Now when I hit the endpoint, I find that the message is sent to both the queues. I know this because I tailed the log and found that the message is printed twice.
How can I make the message go to only one of the queues?
EDIT:
Instead of scaling the HttpSink within Pivotal Cloud Foundry, I deployed HttpSink as two different apps. But in the application.properties they belonged to the same group. One of them had instanceIndex=0 and the other intanceIndex=1.
Even now, I get a single queue with binding as "#" and two consumers to that queue.
How can I make different instances of HttpSink create their own queue and the message from HttpSource gets routed to one of them based on the partitionKey?

A:

I didn't notice before - you are missing consumer. from the property:
spring.cloud.stream.bindings.input.consumer.partitioned=true

See the documentation.
Are you using an IDE to create the properties file? My version of STS (3.8.1) flagged this as an issue when I copied in your properties.
I just ran a test and the queue is correctly named and bound to the exchange with the correct key.
EDIT
To get it to scale properly on PCF, I also had to comment out the instanceIndex property (presumably because it overrides the PCF environment property) otherwise I got 2 consumers on the -0 queue. With that property removed I got 2 queues as expected.

