Skip to content

Custom Camel routes

A camel-route ingestion is a route written in Camel’s YAML DSL. The route’s from and steps make the payload; the runtime then splits it and creates jobs exactly as for any other source, and reports exchanges and failures the same way. Use it for what the built-in kinds do not cover: an unusual HTTP exchange, a body to reshape before it is split, a component the other kinds do not use.

Prefer a built-in kind when one fits. Built-ins keep a payload until its jobs exist (a file moved to .done/ only then, a message acknowledged only then), set unreadable ones aside, keep watermarks and cursors, and read the ingestion’s secrets for its client. A route does what its own steps say and nothing more. If you need Java, write an extension instead.

The runtime reports the camel-route kind, and runs its ingestions, only when INGEST_CAMEL_ROUTES_ENABLED is true (default false). Without it the kind does not exist for the platform: no form offers it, and an ingestion of the kind shows “no runtime carries this kind”.

A route runs with the runtime’s own identity, network and environment, so it can reach anything the runtime can. The platform therefore refuses to create or change one unless the caller is anchor tier, holds platform:ingestion:ingestion:route, and is either:

  • a pipeline: a service account with the role platform:ingestion-route-author (which also carries bind-secrets). It pushes routes through the API as drafts; it holds no promote, so an administrator makes them live; or
  • an ingestion administrator (platform:ingestion-admin), for example pushing with fcdev ingest apply.

Anyone else, an operator included, is refused: below anchor tier with INGESTION_ROUTE_ANCHOR_REQUIRED, a person with the permission but not an administrator with INGESTION_ROUTE_PIPELINE_REQUIRED. A client’s or a partner’s user can never write a route. Removing a route ingestion needs only delete.

The ingestion’s own secrets are not handed to a route, and the runtime’s outbound address checks do not apply to a route’s own steps. Treat route authorship as running code on the runtime.

On the platform the source is {kind: custom, type: camel-route, settings: {yaml: "..."}}. A definition file writes kind: camel-route and yaml: beside it:

source:
kind: camel-route
yaml: |
from:
uri: timer:acme-fuel-prices
parameters:
period: 900000
steps:
- to:
uri: https://prices.example.org/v2/latest.csv
split: {kind: csv, header: true}

The YAML holds one route and nothing else:

  • at the top: from:, or route: holding from: (and optionally id and description);
  • in from: uri, and optionally parameters, steps, id, description;
  • not allowed: beans, routeConfiguration, rest, templates, or a second route.

The platform stores the YAML without reading it. The runtime checks it when it takes the ingestion (a route it cannot use is reported FAILED with why), and at test connection, which checks the YAML and reports NOT_SUPPORTED for a valid route: a route is never run for a test, because it would act on its own sources.

The body the last step leaves is the payload, handed to the split. A step that throws is a SOURCE failure: the exchange fails, the route shows FAILING until a payload gets through, and a from component that can offer the message again does. A route runs on one runtime at a time, under a lease.

Idempotency: say where the payload came from

Section titled “Idempotency: say where the payload came from”

A route’s jobs carry no idempotency key unless a step says where the payload came from, in the exchange property ingestPayloadIdentity. It must name the payload and be the same every time it is read, never its content alone. Each record’s key is then the SHA-256 of that identity and the record’s position:

- setProperty:
name: ingestPayloadIdentity
simple: "prices.example.org/v2/latest@${header[Last-Modified]}"

Without it, a payload read twice (after a failed dispatch, say) makes its jobs twice.

The components and languages the runtime is built with: timer, http and https, log, direct, sftp and ftp, aws2-sqs, aws2-s3, and Camel’s core languages (simple, constant, header and so on). JSONPath, jq, Groovy and others are not in the build. A deployment that needs one builds its own runtime image on the standard one, adding the dependency to its ingestor-runtime assembly.

A body made without any source, for a heartbeat or a demo (with split: {kind: json, arrayPath: $}):

from:
uri: timer:acme-heartbeat
parameters:
period: 60000
includeMetadata: true
steps:
- setBody:
simple: '[{"beat": ${header.CamelTimerCounter}, "at": "${date:now:yyyy-MM-dd''T''HH:mm:ssXXX}"}]'

Dispatch only some answers. A filter’s own steps run when it matches, and the steps after it run either way. To drop an exchange, stop it inside a filter that matches what is not wanted:

from:
uri: timer:acme-status
parameters:
period: 300000
steps:
- to:
uri: https://status.acme.example/api/incidents
- filter:
simple: "${body} not contains 'OPEN'"
steps:
- stop: {}

A stopped exchange is not dispatched and is not a failure; the rest go on to the split.

  • Pushing from a pipeline: the pipeline’s service account saves a draft; an ingestion administrator reviews it (the YAML is in the version) and promotes it. See Definition files and sets.
  • A route that polls an upstream on a timer has no watermark. Make the upstream request idempotent or set ingestPayloadIdentity.
  • Failures are paced like any source. See Troubleshoot ingestion.