title: Spring Cloud Function - Separate routing-expression for different Consumer
body: <p>I have a service, which receives different structured messages from different message queues. Having <code>@StreamListener conditions</code> we can choose at every message type how that message should be handled. As an example:</p>
  
  <p>We receive two different types of messages, which have different header fields and values e.g. </p>
  
  <p>Incoming from "order" queue: </p>
  
  <pre><code>Order1: { Header: {catalog:groceries} }
  Order2: { Header: {catalog:tools} }
  </code></pre>
  
  <p>Incoming from "shipment" queue:</p>
  
  <pre><code>Shipment1: { Header: {region:Europe} }
  Shipment2: { Header: {region:America} }
  </code></pre>
  
  <p>There is a binding for each queue, and with according <code>@StreamListener</code> I can process the messages by catalog and region differently</p>
  
  <p>e.g. </p>
  
  <pre><code>@StreamListener(target = OrderSink.ORDER_CHANNEL, condition = "headers['catalog'] == 'groceries'")
  public void onGroceriesOrder(GroceryOder order){
  ...
  }
  </code></pre>
  
  <p><strong>So the question is</strong>, how to achieve this with the new Spring Cloud Function approach? </p>
  
  <p>At the documentation <a href="https://cloud.spring.io/spring-cloud-static/spring-cloud-stream/3.0.2.RELEASE/reference/html/spring-cloud-stream.html#_event_routing" rel="noreferrer">https://cloud.spring.io/spring-cloud-static/spring-cloud-stream/3.0.2.RELEASE/reference/html/spring-cloud-stream.html#_event_routing</a> it is mentioned:</p>
  
  <p><code>Also, for SpEL, the root object of the evaluation context is Message so you can do evaluation on individual headers (or message) as well …​.routing-expression=headers['type']</code></p>
  
  <p>Is it possible to add the routing-expression to the binding like (in <code>application.yml</code>)</p>
  
  <pre><code>onGroceriesOrder-in-0:
    destination: order
    routing-expression: "headers['catalog']==groceries"
  </code></pre>
  
  <p>?</p>
  
  <p><strong>EDIT after first answer</strong> 
  If the above expression at this location is not possible, what the first answer implies, than my question goes as follows:</p>
  
  <p>As far as I understand, an expression like <code>routing-expression: headers['catalog']</code> must be set globally, because the result maps to certain (consumer) functions.</p>
  
  <p>How can I control that the 2 different messages on each queue will be forwarted to their own consumer function, e.g.</p>
  
  <pre><code>Order1 --&gt; MyOrderService.onGroceriesOrder()
  Order2 --&gt; MyOrderService.onToolsOrder()
  Shipment1 --&gt; MyShipmentService.onEuropeShipment()
  Shipment2 --&gt; MyShipmentService.onAmericaShipment()
  </code></pre>
  
  <p>That was easy with <code>@StreamListener</code>, because each method gets their own <code>@StreamListener</code> annotation with different conditions. How can this be achieved with the new <code>routing-expression</code> setting?
  ?</p>