# Content-Based Routing

Content-based routing directs a request or message to a destination by evaluating its payload, attributes, or derived meaning.

Cloud concept. Updated 2026-10-29. Page: https://blowstack.com/tools/cloud-concepts-hub/content-based-routing

> Instead of distributing requests solely by availability or load, content-based routing selects a destination suited to each request’s characteristics. In generative AI applications, it can match tasks to specialized foundation models while balancing quality, latency, cost, and security constraints.

Practice exams covering Content-Based Routing: [ANS-C01 AWS Certified Advanced Networking - Specialty](https://blowstack.com/practice-exams/aws-certified-advanced-networking-specialty), [DVA-C02 AWS Certified Developer - Associate](https://blowstack.com/practice-exams/aws-certified-developer-associate), [DOP-C02 AWS Certified DevOps Engineer - Professional](https://blowstack.com/practice-exams/aws-certified-devops-engineer-professional), [AIP-C01 AWS Certified Generative AI Developer - Professional](https://blowstack.com/practice-exams/aws-certified-generative-ai-developer-professional), [SAA-C03 AWS Certified Solutions Architect - Associate](https://blowstack.com/practice-exams/aws-certified-solutions-architect-associate), [SAP-C03 AWS Certified Solutions Architect - Professional](https://blowstack.com/practice-exams/aws-certified-solutions-architect-professional).

## 6 key aspects of Content-Based Routing

Effective content-based routing combines request interpretation, explicit eligibility rules, measured optimization, and observable failure handling.

1. **Request-aware destination selection**: Inspect structured attributes or derive features from the payload to select a processing destination. Use trusted metadata where possible, and validate client-provided routing hints before applying them.
2. **Static rules and runtime classification**: Use predefined mappings for predictable categories and runtime classifiers when task intent must be inferred. A hybrid design can avoid classifier overhead for requests that deterministic rules already resolve.
3. **Constraint-first model eligibility**: Filter candidates by modality, context capacity, authorization, and data-handling requirements before comparing cost or latency. Never let an optimization policy select a model that cannot safely process the request.
4. **Measured quality, cost, and latency**: Base selection policies on representative model evaluations and operational telemetry. Track performance by task category and include routing overhead when calculating end-to-end cost and latency.
5. **Explicit defaults and constrained fallbacks**: Define what happens when classification is ambiguous, no eligible destination exists, or a model fails. Bound retries and ensure every fallback satisfies the original request’s security and capability constraints.
6. **Traceable routing policies**: Version routing rules and record why each destination was chosen. Use these records to reproduce decisions, compare policy versions, and detect regressions without retaining unnecessary sensitive content.

## Cloud services for Content-Based Routing

API Gateway can validate requests and normalize routing metadata before invoking Lambda or starting a Step Functions workflow. Lambda applies deterministic rules or derives classification attributes, and Step Functions coordinates branches, model calls, retries, and constrained fallbacks. Amazon Bedrock supplies eligible foundation models and, where its supported configurations fit the use case, managed prompt-routing capabilities. CloudWatch captures decision logs and operational measurements that inform policy updates. Together, these services separate API handling, selection logic, execution, and observation; quality evaluations and security constraints still need to be designed explicitly rather than inferred from infrastructure metrics.

- **[AWS Step Functions](https://blowstack.com/tools/cloud-services-hub/aws-step-functions)**: Orchestrates classification, branching, model invocation, and fallback handling. Choice states route on structured workflow data, so semantic decisions require a preceding classifier or application task that produces usable routing attributes.
- **[AWS Lambda](https://blowstack.com/tools/cloud-services-hub/aws-lambda)**: Runs application code for static routing tables, request classification, eligibility checks, and metrics-informed model selection. Functions can validate routing inputs and invoke the selected model through its API.
- **[Amazon Bedrock](https://blowstack.com/tools/cloud-services-hub/amazon-bedrock)**: Provides foundation model APIs that an application or workflow can select according to task requirements. Its intelligent prompt routing capability can also select between supported models within configured router options; it should not be treated as an unrestricted router across arbitrary models or endpoints.
- **[Amazon API Gateway](https://blowstack.com/tools/cloud-services-hub/amazon-api-gateway)**: Provides the API entry point for authentication, validation, and supported request transformations. REST API mapping templates can prepare routing metadata for a backend, while complex content interpretation and arbitrary model selection remain backend responsibilities.
- **[Amazon CloudWatch](https://blowstack.com/tools/cloud-services-hub/amazon-cloudwatch)**: Collects logs and operational metrics used to evaluate routing behavior, including per-route latency, errors, and custom measurements. Routing code must consume or otherwise incorporate these signals into its policy; CloudWatch does not select models automatically.

## Content-Based Routing exam questions

Real practice exam questions on Content-Based Routing, with the correct answer and its explanation.

### Question 1 (DVA-C02)

**Question:**

A media-processing application publishes upload notifications to an Amazon SNS topic. Every notification includes a String message attribute named mimeType, with values such as image/jpeg, image/png, or application/pdf. Uploads awaiting security review also include a String message attribute named quarantined with the value "true". Other uploads omit the quarantined attribute. The JSON message body contains only the object's bucket and key.

A thumbnail-generation function subscribes to the topic but currently receives every notification. A developer must configure this subscription to receive only notifications whose mimeType starts with image/ and whose quarantined attribute is absent. Unwanted notifications must be filtered before delivery, without changing the publisher.

Which subscription configuration meets these requirements?

**Correct answer:** Set FilterPolicyScope to MessageAttributes and set FilterPolicy to {"mimeType":[{"prefix":"image/"}],"quarantined":[{"exists":false}]}.

**Explanation:** MessageAttributes filtering evaluates the supplied SNS attributes. The prefix condition matches image MIME types, and exists:false requires the quarantined attribute to be absent. Conditions for different attribute names are combined with AND, so SNS delivers only notifications that satisfy both requirements.

### Question 2 (SAP-C03)

**Question:**

A company centralizes operational events from 40 AWS accounts on a custom Amazon EventBridge event bus named operations in a shared-services account. Each workload account has a rule that forwards events directly to this bus. Some workload accounts are in different AWS Regions, and the destination Region supports cross-Region event-bus routing. The forwarding roles and destination bus policy are configured correctly. An archive on the operations bus confirms that forwarded events are arriving.

All workload accounts publish events with source "com.example.batch" and detail-type "Batch Failed". The detail object contains only jobId and status. A remediation workflow in the shared-services account must run only for events originating in two designated production accounts. Events from all other accounts must continue arriving on the operations bus for other consumers.

An existing rule targets the remediation workflow and matches the source, detail-type, and the shared-services account ID in the top-level account field. However, the rule was deployed on the shared-services account's default event bus, and the workflow is never invoked. Target invocation permissions are already correct.

Which change will meet the requirements without modifying the publishers or forwarding rules?

**Correct answer:** Create the remediation rule on the operations bus. Match the existing source and detail-type values and match the two production account IDs in the top-level account field. Remove the ineffective default-bus rule.

**Explanation:** Receiving rules must be attached to the bus that receives the forwarded events. Cross-account forwarding preserves the originating account in the event's top-level account field. A rule on the operations bus that matches the two production account IDs invokes remediation only for those accounts while leaving other events available to other consumers.

### Question 3 (SAA-C03)

**Question:**

A company exposes a document-processing API through an Application Load Balancer (ALB) that terminates HTTPS on port 443. The ALB forwards all requests to a fleet of EC2 reverse proxies. Each proxy inspects the HTTP header X-Processing-Class: requests with the value economy go to a low-cost processing fleet, and all other requests go to a standard processing fleet. Both processing fleets span two Availability Zones and accept requests directly from the ALB.

All clients use the same hostname and POST /process path. Clients cannot change their URLs, ports, or request format. The company wants to eliminate the reverse proxy fleet's compute costs while preserving the routing behavior and Availability Zone resilience.

Which solution meets these requirements?

**Correct answer:** Create a target group for each processing fleet. Configure the existing HTTPS listener to forward requests to the economy target group when the HTTP header X-Processing-Class equals economy, and use the standard target group as the default action. Remove the reverse proxy fleet.

**Explanation:** An ALB listener rule can inspect an HTTP header and forward matching requests to a specific target group. A header condition for X-Processing-Class equal to economy, followed by a default action to the standard fleet, preserves the existing behavior. Registering each fleet's targets across both Availability Zones retains resilience while removing the proxy compute costs.

### Question 4 (AIP-C01)

**Question:**

A SaaS company uses an AWS Lambda function to route requests to Amazon Bedrock foundation models. A trusted task field directs code-generation requests to an established coding model and all other requests to a general-purpose model.

The company wants to evaluate a replacement coding model with approximately 10% of eligible tenants. A tenant is eligible only if its administrator has enabled the experiment. Throughout the experiment, all code-generation requests from the same eligible tenant must use the same model, regardless of prompt, retries, Lambda scaling, or execution-environment replacement. Ineligible tenants must continue using the established coding model, and other tasks must continue using the general-purpose model.

The authenticated tenant ID and experiment configuration are available to the function. The company does not want to store tenant-to-model assignments. Which implementation best meets these requirements?

**Correct answer:** For code-generation requests, check experiment eligibility and compute a stable cryptographic hash of the authenticated tenant ID and a fixed experiment identifier. Map the hash to 100 buckets and route eligible tenants in 10 designated buckets to the replacement model. Route remaining code-generation requests to the established model and other tasks to the general-purpose model.

**Explanation:** A stable hash provides deterministic tenant assignment without storing assignments. Including a fixed experiment identifier keeps the assignment stable throughout the experiment while allowing independent future experiments. Checking the task and eligibility before applying the split preserves routing for ineligible tenants and other tasks. Hash bucketing produces an approximate, rather than exact, 10% tenant cohort.

### Question 5 (DOP-C02)

**Question:**

A company's security platform publishes custom findings to an Amazon EventBridge event bus. Every finding has source `com.example.security`, detail-type `FindingAssessed`, and two scalar fields in detail: `responseMode`, which is either `AUTOMATIC` or `MANUAL`, and `confidence`, which is a JSON number from 0 through 100.

An existing containment workflow must receive only findings whose responseMode is AUTOMATIC and whose confidence is at least 90. Every other finding must go to an existing analyst-review workflow. A finding must never be routed to both workflows, although duplicate deliveries to the selected workflow are acceptable.

A DevOps engineer must implement this routing without changing the publisher or workflow code and without introducing an intermediate processor. Target invocation permissions are already configured.

Which configuration meets these requirements?

**Correct answer:** Create a containment rule that matches responseMode AUTOMATIC and confidence numerically greater than or equal to 90. Create an analyst-review rule with a detail-level `$or` that matches responseMode MANUAL or confidence numerically less than 90. Include the specified source and detail-type in both rules, and configure each workflow as the target of its corresponding rule.

**Explanation:** The containment condition and the analyst-review condition are complementary for the stated field values. A finding that does not satisfy AUTOMATIC AND confidence >= 90 must have responseMode MANUAL OR confidence < 90. EventBridge supports numeric comparisons and `$or` in event patterns, so the rules select exactly one workflow for every finding without custom filtering code.

### Question 6 (ANS-C01)

**Question:**

A company is separating an HTTPS inventory API into independently scalable read and write fleets. Both fleets run on EC2 instances across three Availability Zones. Clients must continue using the same hostname, URL paths, and port. GET and HEAD requests must reach only the read fleet. POST, PUT, and DELETE requests must reach only the write fleet. All other HTTP methods must receive an HTTP 405 response from the ingress layer without reaching either fleet.

Clients can send requests with different methods over the same persistent connection. The company requires managed load balancing with TLS termination at ingress, without modifying clients or backend applications or deploying a separate proxy tier.

Which configuration meets these requirements?

**Correct answer:** Deploy an Application Load Balancer across three Availability Zones with an HTTPS listener. Create separate target groups for the read and write fleets. Add HTTP request method rules that forward GET and HEAD to the read target group and POST, PUT, and DELETE to the write target group. Configure the listener's default action to return a fixed HTTP 405 response.

**Explanation:** An Application Load Balancer evaluates HTTP request method conditions for each request, including requests sharing a persistent connection. Separate forwarding rules deterministically select the appropriate fleet. A default fixed-response action returns HTTP 405 for methods that match neither rule, without forwarding them to a backend.

## Practice Content-Based Routing in a full exam

Questions on Content-Based Routing in each practice exam, with every answer option and an explanation for each:

- [AIP-C01](https://blowstack.com/practice-exams/aws-certified-generative-ai-developer-professional): 9 questions
- [ANS-C01](https://blowstack.com/practice-exams/aws-certified-advanced-networking-specialty): 7 questions
- [DVA-C02](https://blowstack.com/practice-exams/aws-certified-developer-associate): 4 questions
- [SAP-C03](https://blowstack.com/practice-exams/aws-certified-solutions-architect-professional): 4 questions
- [SAA-C03](https://blowstack.com/practice-exams/aws-certified-solutions-architect-associate): 2 questions
- [DOP-C02](https://blowstack.com/practice-exams/aws-certified-devops-engineer-professional): 1 question

## What is Content-Based Routing

Content-based routing is an integration pattern in which a router examines a request or message and selects an appropriate destination. Routing inputs can include structured fields, headers, language, document type, task category, or features extracted from unstructured text. The destination might be a processing workflow, service endpoint, queue, or foundation model. The defining characteristic is that the request’s content or attributes influence the decision, rather than every request following the same path.

For foundation model integrations, a router might send straightforward classification tasks to a smaller model, source-code questions to a model evaluated for coding, and image-containing requests to a model that supports the required modality. A long document may require a model with a larger context window. These decisions should start with eligibility constraints, such as supported input formats, regional availability, data-handling requirements, and context limits, before optimizing cost or response time.

A static routing configuration uses predefined rules, often implemented in application code or a versioned configuration file. For example, a trusted task field with the value translation can map to a particular model endpoint. Static does not mean every request uses the same model: it means the selection policy is predefined rather than learned or adjusted automatically. Explicit rules are inexpensive and explainable, but become harder to maintain when categories overlap or inputs lack reliable structure.

Dynamic routing can derive a task category or complexity estimate at runtime. A classifier can examine the prompt and return a validated label, after which an orchestrator selects a specialized model. In AWS Step Functions, a classification task can populate workflow state and a Choice state can branch on that result. Choice states evaluate configured conditions; they do not independently understand natural language. Calling a classifier adds latency and cost, so a simple rules-first path is often appropriate for clearly identifiable requests.

Metrics-driven routing adds measured model performance to the decision. Evaluate candidate models on representative task categories and record quality scores, token costs, latency distributions, throttling, and failure rates. A routing policy can select the lowest-cost eligible model that meets a quality target and latency objective. Quality usually requires offline evaluation or application feedback rather than an infrastructure metric alone. Update policies through controlled releases and monitor performance by task category so aggregate averages do not hide poor routing for less common requests.

An API gateway can authenticate clients, validate request structure, and transform incoming fields into a consistent routing envelope. For example, an Amazon API Gateway REST API mapping template can normalize task metadata before forwarding it to a routing backend. Request transformation is not equivalent to arbitrary semantic model selection, and transformation capabilities differ by API type. Keep complex classification and model-selection logic in application code or an orchestrated workflow rather than assuming the gateway automatically chooses a model from the request body.

Production designs need an explicit default route, handling for ambiguous classifications, and bounded retries or fallback paths. A fallback must preserve security and capability requirements; an unavailable approved model is not permission to send sensitive data elsewhere. Treat client-supplied routing hints and classifier output as untrusted input, and map them to an allowlisted set of destinations. Record the policy version, selected model, decision reason, and relevant operational metrics without unnecessarily logging sensitive prompts. Unlike ordinary load balancing, content-based routing matches requests to capabilities; it can use load signals, but distributing traffic alone does not make a system content-aware.

## Learn Content-Based Routing in lessons

5 short lessons on Content-Based Routing in 4 certification courses.

- SAP-C03: Content-Based Routing: Event Patterns for Selective Forwarding (Premium), https://app.blowstack.com/lessons/content-based-routing-event-patterns-for-selective-forwarding-sap-c03
- SAA-C03: Content-Based Routing: matching requests to destinations (Premium), https://app.blowstack.com/lessons/content-based-routing-matching-requests-to-destinations-saa-c03
- AIP-C01: Content-Based Routing: foundation model selection policies (Premium), https://app.blowstack.com/lessons/content-based-routing-foundation-model-selection-policies-aip-c01
- DOP-C02: Content-Based Routing: unambiguous event-routing policies (Premium), https://app.blowstack.com/lessons/content-based-routing-unambiguous-event-routing-policies-dop-c02
- SAA-C03: Content-Based Routing vs Load Balancing (Premium), https://app.blowstack.com/lessons/content-based-routing-vs-load-balancing-saa-c03
