Skip to main content

Content Based Routing

Use Content Based Routing to inspect each message and send it to the recipient that handles that message shape, value, or rule outcome.

The pattern is implemented at the decision point where the flow has enough message content to choose the next recipient. Use a match-based route for stable routing keys, and use predicate-based routing when the route depends on ranges, optional fields, or multiple content checks.

Pattern-based content routing

Use pattern-based content routing with match expressions when each recipient maps to a known field value, such as a message type, region, product category, or event name. Keep an explicit default branch so unsupported content is handled in a dedicated fallback path for invalid recipients.

  1. Create or open the HTTP service resource that receives the routed message.
  2. Add HTTP client connections for each recipient. See adding a connection and the HTTP client reference.
  3. Open the resource flow and add a step.
  4. Add a Match node and set the expression to the routing field, such as order.itemType.
  5. Add one branch for each accepted value, such as "standard" and "express", and add _ as the default branch.
  6. In each accepted branch, add the connector call for that recipient and return the route result.
  7. In the default branch, return an error response for unsupported content.

Predicate-based content routing

Use predicate-based content routing with if/else statements when the route depends on content rules instead of one stable routing key.

  1. Create or open the resource or function that contains the routing decision.
  2. Add HTTP client connections for the possible recipients. See adding a connection and the HTTP client reference.
  3. Add a configurable variable for any route rule that should change by environment, such as bulkThreshold.
  4. Open the flow and add an If node with a condition such as order.quantity >= bulkThreshold.
  5. Add the bulk recipient call inside the True branch.
  6. In the False branch, add another If node with a condition such as order.priority.
  7. Add the priority recipient call inside the nested True branch and the default recipient call inside the nested False branch.
  8. Return the selected route result from each branch.