Write an extension
An extension adds a kind of source beyond the built-in ones. It tells the platform what an ingestion of its
kind is configured with (the runtime reports the fields; the console draws the form from them), and it turns
one ingestion’s settings into the Camel endpoint that ingestion’s route consumes from. Everything after the
endpoint belongs to the runtime, as for a built-in kind: the split, the jobs, the counts, the failures,
FAILING, and the lease that keeps a polled source on one runtime at a time.
Write an extension when a source needs Java: a vendor API with state of its own (a feed token, a call per
asset), a client SDK, a protocol. For what a few Camel steps can do, a
Camel route is lighter. The worked example in the repository is
ingestor/ingestor-extensions/generator, which makes up records on a schedule.
On the platform an extension’s source is {kind: custom, type: <type>, settings: {...}}. A definition file
writes kind: <type> with the settings beside it, a secret setting as the secret’s name:
source: kind: generator every: PT10S count: 3How the runtime gets it
Section titled “How the runtime gets it”Three ways; the class path mixes with either of the others, but the directory and the manifest are exclusive:
- A jar in
INGEST_EXTENSIONS_DIR. The runtime loads every*.jarthere at start, each with its own class loader whose parent is the runtime’s. The jar sees the contract, the extension API and Camel, and not other extension jars. It must hold what it needs beyond those (shade it) and must not bundleingestor-contractoringestor-extension. Underfcdevthe folder is~/.flowcatalyst/ingestor-extensions. - A pinned manifest in S3 (
INGEST_EXTENSIONS_MANIFEST), for deployed runtimes. See below. - On the class path, in a build that depends on
ingestor-runtimeand the extension module.
Either way the extension is found with ServiceLoader through
META-INF/services/io.flowcatalyst.ingestor.extension.IngestExtension, one line: the extension’s class name.
The runtime refuses to start, naming the jar, when the jar declares no extension API or another major version than the runtime’s, lists no extension, takes a type twice, has a malformed kind, or has a default that does not satisfy its own field.
The extension API version
Section titled “The extension API version”ExtensionApi.MAJOR is the major version of the extension API. It changes only when an existing extension
would stop working. A jar declares the major it was built against in its manifest:
<plugin> <artifactId>maven-jar-plugin</artifactId> <configuration> <archive> <manifestEntries> <Ingestor-Extension-Api>1</Ingestor-Extension-Api> </manifestEntries> </archive> </configuration></plugin>Deployed: a pinned manifest in S3
Section titled “Deployed: a pinned manifest in S3”A deployed runtime cannot write its extensions directory, so it loads jars named by a manifest. Set
INGEST_EXTENSIONS_MANIFEST=s3://<bucket>/<key>. Unset, nothing changes.
{"version": 1, "environment": "staging", "publishedAt": "2026-10-29T12:00:00Z", "source": {"repository": "acme/extensions", "commit": "<40-hex sha>"}, "extensions": [{"name": "ingest-extension-vendor", "version": "0.1.0", "key": "jars/ingest-extension-vendor-0.1.0-<sha12>.jar", "sha256": "<64 lowercase hex>"}]}key is an object key in the same bucket as the manifest. Names are unique and match [a-z0-9][a-z0-9.-]*.
Unknown fields are ignored; a version other than 1 is refused.
At start the runtime fetches the manifest, downloads each jar into a fresh directory only its process can
read (computing SHA-256), and loads exactly those jars with the same checks as a directory. Credentials come
from the default AWS provider chain and the region from AWS_REGION; INGEST_AWS_ENDPOINT points it at a
stand-in such as LocalStack. It refuses to start when the extensions directory also holds a jar, when the
manifest cannot be read or is invalid, or when a jar’s SHA-256 differs from the manifest’s. If the manifest
object does not exist, it logs a WARN and starts with no extensions, so the platform never leases an
extension kind to it. The task role needs s3:GetObject and, to get that behaviour (rather than a refusal on a
403), s3:ListBucket too.
The pieces
Section titled “The pieces”<name>/ pom.xml ingestor-contract and ingestor-extension as provided src/main/java/.../<Name>Kind.java implements ExtensionKind: the fields and the rules src/main/java/.../<Name>Extension.java implements IngestExtension: the endpoint, a test src/main/java/.../<Name>Endpoint.java usually a PolledSource src/main/resources/META-INF/services/ io.flowcatalyst.ingestor.extension.IngestExtension one line: the extension's class nameExtensionKind: what an ingestion is configured with
Section titled “ExtensionKind: what an ingestion is configured with”public final class GeneratorKind implements ExtensionKind {
private static final SourceKind KIND = new SourceKind( "generator", // the type: lowercase words joined by '-', not a built-in kind's "Generator", // for people, in the kind list "Made-up records on a schedule, for trying an ingestion out.", List.of( SourceKind.field("every", "Every", Type.DURATION).description("How often a payload is made.") .required().defaultValue("PT10S").between("PT1S", null).rule("must be a second or more").build(), SourceKind.field("count", "Records", Type.INTEGER).defaultValue("1").between("1", "1000").build(), SourceKind.field("template", "Template", Type.MULTILINE).defaultValue("{\"n\": ${n}}").build()));
@Override public SourceKind kind() { return KIND; }}A field has a name (a letter then letters and digits, not kind), a label, a description, a type, whether it
is required, a default and, by type, choices, a pattern, bounds and a rule.
type |
In the settings | Checked | Read with |
|---|---|---|---|
TEXT |
a string | pattern, if any; blank is not given |
settings().text(name), requireText(name) |
MULTILINE |
a string | text(name) |
|
CHOICE |
one of choices |
text(name) |
|
INTEGER |
a number | between(min, max) |
integer(name) |
BOOLEAN |
true or false | flag(name) |
|
DURATION |
ISO 8601, PT30S |
between("PT30S", "PT1H") |
duration(name) |
URL |
an http or https address | url(name) |
|
SECRET |
a secret’s name | not blank | secret(name), requireSecret(name): the revealed Secret |
LIST |
an array of strings | pattern on each item, between on the count |
list(name) |
Rules a field cannot say go in problems(settings, split): a relation between two settings, an address that
must be https, a split the payload does not suit. The runtime checks settings before it builds the
endpoint and reports a failed route with every problem at once.
Secrets. Declare a secret as a SECRET field. The platform cannot tell which settings are secrets, so for
an extension kind every text setting counts as a secret name to the reveal call, and any change of the
settings counts as pointing secrets somewhere new, which needs platform:ingestion:ingestion:bind-secrets.
IngestExtension: the runtime’s part
Section titled “IngestExtension: the runtime’s part”public interface IngestExtension { ExtensionKind kind(); Endpoint endpoint(ExtensionContext context) throws Exception; default @Nullable Tested test(ExtensionContext context, List<String> steps) throws Exception { return null; }}The implementation has a public no-argument constructor and keeps no state of its own: the runtime makes one instance and asks it for a new endpoint per ingestion and version.
ExtensionContext gives:
| Member | Use |
|---|---|
camel() |
The CamelContext the route is added to |
ingestion() |
The ingestion: id, version, client, application, code |
settings() |
Its settings, read by the kind’s fields |
state() |
Small values kept between polls (get, put), such as a watermark or feed token. The platform keeps them, so they follow the ingestion to whichever runtime runs it next; put is refused once this runtime no longer holds the lease |
http() |
The runtime’s HTTP clients: register the extension’s own (registerScoped) so requests are measured, and close the registration when the endpoint stops. The runtime’s address checks do not cover an extension’s own connections: refuse loopback, link-local and metadata addresses yourself |
clientName(prefix) |
A unique name for such a client |
clock() |
The time, which tests set |
conceal(value) |
Keeps a credential obtained while running (a login session, a token) out of traces, wherever it appears. Call it each time one is obtained. An API that puts a session in its URL paths otherwise shows it to anyone who may read trace metadata. Secrets read through settings() need no call |
Throw InvalidSettingsException (message free of secrets) when the settings cannot be used: the ingestion is
reported FAILED. Any other exception is tried again on the runtime’s next turn.
Test connection
Section titled “Test connection”The platform hands a queued test to a runtime that carries the kind; the runtime runs test(context, steps).
Try the source once as the endpoint would, dispatch nothing, add a sentence to steps for each thing done,
and answer Tested(outcome, records) (RESULTS or NO_RESULTS). Throw on failure: the message is the last
step, and a refused login (PolledSource.refusedLogin) is shown as one. The default returns null and the
console says the kind offers no test. A test never reads or writes the ingestion’s state.
The endpoint
Section titled “The endpoint”Each exchange the endpoint produces is one payload. Its body is split by the ingestion’s split, and each record becomes a job. When the jobs cannot be created the exchange fails, so a source that can keep a payload and offer it again (a page read again from its token, a file not moved) should do so, and commit (store the token, move the file) only after a good exchange.
PolledSource fits a source polled with code of your own. poll(payloads) hands any number of payloads to the
route (payloads.dispatch(body) answers whether their jobs exist) and says when to poll again. A poll that
throws anything, an Error included, is reported (AUTH for a refused login, else SOURCE), and the next
poll still comes after the paced wait. SeenKeys remembers what a poll dispatched lately. A
ScheduledPollEndpoint fits too (the generator uses one). The endpoint never produces (createProducer
throws).
Stopping cleanly
Section titled “Stopping cleanly”When a lease is about to expire, a route is moved, or the runtime shuts down, a PolledSource is
suspended, not stopped outright: no further poll is scheduled, and the poll in progress is not interrupted
but asked to stop. From then on:
payloads.dispatch(...)returnsfalseat once without running the route. That is not a failure: it is not reported and the next poll is not delayed.payloads.stopping()istrue, andpolling()says whether a poll is running.
A poll that moves on no further once a dispatch returns false (do not store the cursor past the payload that
was not taken) stops cleanly, and whichever runtime runs the ingestion next reads that payload again:
@Overrideprotected Duration poll(Payloads payloads) throws Exception { for (Rows rows : pages()) { if (!payloads.dispatch(rows.json(), rows.identity())) { break; // not taken (or stopping): do not move past it } seen.add(rows.keys()); } return every;}A source that takes a payload away as it reads it (a queue that empties as it serves, without
acknowledgement) must not lose what it has read: ask stopping() before each read, and dispatch what was read
with payloads.dispatchTaken(body, identity), which runs the route even while stopping. A false from it is
the platform’s answer, never the stop’s. A page the platform did not take can only be kept in memory and is
lost if the route goes away before the next poll.
stopping(), dispatchTaken(...) and polling() are additions to extension API 1. An extension that calls
them needs a runtime that has them (an older one fails the poll with NoSuchMethodError): deploy the runtime
first.
Failures are paced
Section titled “Failures are paced”A PolledSource is paced without doing anything:
- After a successful poll the wait it returned is used, but never less than 250 ms. A loop that returns
Duration.ZEROstill drains a backlog and cannot spin. - A poll that throws, calls
partFailed, or haspayloads.dispatch(...)returnfalseat least once is a failure. Afternfailures in a row the next poll waitsBackoff.FAILURES.delay(n, max(retryDelay(), 1 s))(5 seconds doubling to 5 minutes, with jitter). The first success ends the streak. - A refused login (
PolledSource.refusedLogin) waitsBackoff.REFUSED_LOGIN, 5 minutes doubling to 1 hour, and theAUTHfailure says when it will try again. - The first failure of a streak is logged with its stack trace, then at most one line a minute with a count.
For your own calls, use Backoff (Backoff.FAILURES, or new Backoff(initial, max); delay(n)) and
FailureLog (FailureLog.warn(logger); failed(key, message, cause), recovered(key, message)) from
io.flowcatalyst.ingestor.extension. Key them by what failed, for example the ingestion id and ":poll". Do
not write a loop that retries at once, or log once per attempt. See Troubleshoot ingestion.
Saying where a payload came from
Section titled “Saying where a payload came from”When the source can say where a payload came from, say it. The runtime makes each record’s externalId from
the payload’s identity and the record’s position (SHA-256 of <identity>#<index>), and the platform answers a
record sent again with the job it made first. A page asked for again, a retry after a timeout, or the
ingestion moving to another runtime then makes its jobs once.
The identity names the payload and is the same each time it is read (an asset’s id and version, a page token, a file’s path, size and time). Never the content alone, and two different payloads must never share one.
@Overrideprotected Duration poll(Payloads payloads) throws Exception { Page page = vendor.page(cursor); if (!payloads.dispatch(page.json(), "acme-vendor:orders?page=" + cursor)) { // The platform did not take the jobs; the route has reported why. Ask again later. return Duration.ofSeconds(30); } context.state().put("cursor", page.next()); return page.hasMore() ? Duration.ZERO : Duration.ofMinutes(5);}From a PolledSource use payloads.dispatch(body, identity). From any other endpoint use
PayloadIdentity.set(exchange, identity), which sets the exchange property ingestPayloadIdentity. Without
an identity the jobs carry no key.
Testing
Section titled “Testing”Run the endpoint in a DefaultCamelContext with an ExtensionContext of your own, and a small server that
answers as the vendor does. The runtime’s ExtensionLoadingTest shows how to compile and load a jar from a
directory. Build the runtime with make ingestor-build; under fcdev drop the jar in the extensions folder
and restart (see Ingestion under fcdev).