This is an automated email from the ASF dual-hosted git repository. davsclaus pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/camel-performance-tests.git
commit d855af7521bd3caf91a7df7fdbf4df12e41aff39 Author: Claus Ibsen <[email protected]> AuthorDate: Sun Oct 18 15:03:31 2026 +0200 ai-benchmark: route/dynamic-routing in the new set A recipient list to endpoints computed from the order (warehouse per country, billing per status), a failover load balancer from a primary invoice service that is down to a backup, and a throttle on the US warehouse. The final reference is the example's route file (apache/camel-jbang-examples#117). Reference pass 3/3 twice. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01STT6whBgK1AqsSsUKrnE8m --- ai-benchmark/gen_stepwise.py | 43 ++++++++++++++++++++++ .../route-dynamic-routing/orders/order-1001.json | 2 + .../route-dynamic-routing/orders/order-1002.json | 2 + .../route-dynamic-routing/orders/order-1003.json | 2 + 4 files changed, 49 insertions(+) diff --git a/ai-benchmark/gen_stepwise.py b/ai-benchmark/gen_stepwise.py index 1baa9d6..7b29409 100644 --- a/ai-benchmark/gen_stepwise.py +++ b/ai-benchmark/gen_stepwise.py @@ -955,6 +955,49 @@ EXAMPLES.append({ ]}) +# ---------------------------------------------------------------- route/dynamic-routing (recipient list, failover load balancer, throttle) +DR = "dynamic-routing.camel.yaml" +DR_INCOMING = (UNMARSHAL + log("Order ${body[orderId]} for ${body[country]}, ${body[status]}")) +DR_RECIPIENTS = (" - recipientList:\n expression:\n simple:\n" + " expression: \"direct:warehouse-${body[country]},direct:billing-${body[status]}\"\n") +def dr_warehouse(country, throttle=False): + steps = (" - throttle:\n expression:\n constant:\n expression: \"1\"\n" + " timePeriodMillis: 1000\n" if throttle else "") + log("Warehouse " + country + " picks ${body[orderId]}") + return route("warehouse-" + country, DIRECT("warehouse-" + country), steps) +DR_FAILOVER = (" - loadBalance:\n failoverLoadBalancer:\n inheritErrorHandler: false\n" + " exception:\n - java.lang.IllegalStateException\n steps:\n" + " - to:\n uri: direct:invoice-primary\n - to:\n uri: direct:invoice-backup\n") +DR_PENDING = route("billing-pending", DIRECT("billing-pending"), log("No invoice for ${body[orderId]} until it is paid")) +DR_PRIMARY = ("- route:\n id: invoice-primary\n errorHandler:\n noErrorHandler: {}\n from:\n" + DIRECT("invoice-primary") + + " steps:\n - throwException:\n exceptionType: java.lang.IllegalStateException\n" + " message: \"The invoice service is down\"\n") +DR_BACKUP = route("invoice-backup", DIRECT("invoice-backup"), log("Invoice for ${body[orderId]} via the backup service")) +def dr_state(failover, throttle): + parts = [route("incoming-orders", FILE_ORDERS, DR_INCOMING + DR_RECIPIENTS), dr_warehouse("DK"), dr_warehouse("DE"), + dr_warehouse("US", throttle), + route("billing-paid", DIRECT("billing-paid"), DR_FAILOVER if failover else log("Invoice for ${body[orderId]}")), + DR_PENDING] + if failover: + parts += [DR_PRIMARY, DR_BACKUP] + return "\n".join(parts) +EXAMPLES.append({ + "name": "route-dynamic-routing", "route_file": DR, "props_file": "application.properties", "wait_seconds": 8, + "seed": "route-dynamic-routing", "steps_dir": NEW, + "initial": {DR: route("incoming-orders", FILE_ORDERS, DR_INCOMING), "application.properties": "# application properties\n"}, + "steps": [ + {"request": "Send each order with a recipient list to two endpoints computed from the order: direct:warehouse-<country> and direct:billing-<status>. Add a route for each: warehouse-DK, warehouse-DE and warehouse-US log \"Warehouse <country> picks ${body[orderId]}\", billing-paid logs \"Invoice for ${body[orderId]}\", and billing-pending logs \"No invoice for ${body[orderId]} until it is paid\".", + "check": {"file_regex": "recipientList", "log_regex": ["Warehouse DK picks ORD-1001", "Warehouse US picks ORD-1003", "Invoice for ORD-1001", "No invoice for ORD-1003 until it is paid"]}, + "reference": {DR: dr_state(False, False)}}, + {"request": "The invoice service has a primary and a backup. Bill a paid order through a failover load balancer: first a route invoice-primary, which is down (it throws an IllegalStateException), then a route invoice-backup that logs \"Invoice for ${body[orderId]} via the backup service\".", + # the primary fails on every paid order: a correct failover that leaves the error handler's log is fine too + "check": {"file_regex": "failover", "log_regex": ["Invoice for ORD-1001 via the backup service", "Invoice for ORD-1002 via the backup service"], "errors_ok": True}, + "reference": {DR: dr_state(True, False)}}, + {"request": "The US warehouse takes at most one order per second: throttle the route warehouse-US.", + "check": {"file_regex": "throttle", "log_regex": "Warehouse US picks ORD-1003", "errors_ok": True}, + "reference": {DR: dr_state(True, True)}}, + ]}) + + def write_project(ex): d = os.path.join(PROJECTS, ex["name"]) shutil.rmtree(d, ignore_errors=True) diff --git a/ai-benchmark/seed/route-dynamic-routing/orders/order-1001.json b/ai-benchmark/seed/route-dynamic-routing/orders/order-1001.json new file mode 100644 index 0000000..3eb5f03 --- /dev/null +++ b/ai-benchmark/seed/route-dynamic-routing/orders/order-1001.json @@ -0,0 +1,2 @@ +{"orderId": "ORD-1001", "customer": "C-482", "country": "DK", "status": "paid", + "lines": [{"sku": "CAMEL-TSHIRT", "qty": 2, "price": 19.95}, {"sku": "CAMEL-MUG", "qty": 1, "price": 9.50}]} diff --git a/ai-benchmark/seed/route-dynamic-routing/orders/order-1002.json b/ai-benchmark/seed/route-dynamic-routing/orders/order-1002.json new file mode 100644 index 0000000..bb7aa0e --- /dev/null +++ b/ai-benchmark/seed/route-dynamic-routing/orders/order-1002.json @@ -0,0 +1,2 @@ +{"orderId": "ORD-1002", "customer": "C-207", "country": "DE", "status": "paid", + "lines": [{"sku": "CAMEL-MUG", "qty": 3, "price": 9.50}]} diff --git a/ai-benchmark/seed/route-dynamic-routing/orders/order-1003.json b/ai-benchmark/seed/route-dynamic-routing/orders/order-1003.json new file mode 100644 index 0000000..9edab76 --- /dev/null +++ b/ai-benchmark/seed/route-dynamic-routing/orders/order-1003.json @@ -0,0 +1,2 @@ +{"orderId": "ORD-1003", "customer": "C-134", "country": "US", "status": "pending", + "lines": [{"sku": "CAMEL-TSHIRT", "qty": 1, "price": 19.95}, {"sku": "CAMEL-CAP", "qty": 1, "price": 14.00}, {"sku": "CAMEL-MUG", "qty": 2, "price": 9.50}]}
