A Camel consumer route as a message source
(Alternera.Plugin.Provisional.Source), which a source trigger
reads: a route on one of the tenant's Camel hosts that ends at
alternera:source:<name> parks each delivery its consumer gets, and the
trigger's runner takes them, runs a pipeline once per message and settles
each by how its run ended. The host's side is Sources in its runtime
(host_runtime). A RabbitMQ (spring-rabbitmq) delivery is settled on its
channel; any other consumer's by how its exchange completes (GenericSource
there): done for an ack, failed for a reject, a retry or a give-back, the
route's own error handling deciding.
Its settings: host, the Camel host, source, the name its route ends
at, and delivery, how the messages reach the proxy:
push(the default): the host sends each delivery as it comes, over the host's frame channel, to an inbox on the proxy (Plugins.Camel.Inbox), while fewer than the trigger's prefetch are held; a receive takes from the inbox and polls nothing. The open, settle, extend and close aresourceframes (Host.source/3) to the member the source opened on, so any host protocol serves, and they are not recorded (record_source_callshas nothing to record);pull: the runner long-polls the host over its HTTP channel, so the host'sprotocolmust serve HTTP (:http1,:http2,:https1or:https2).
How long a poll waits, how long a message is held and how many come at once are the runner's.
A pulled source's calls go over the host's HTTP channel (PluginHosts.Endpoint), each
through Plugin.Provisional.Outbound with the host as its upstream, as a
Camel step's calls do, so the trigger's record_source_calls records
them; they are the plugin's calls, made as no proxy user:
- open:
POST /sources/<name>/openwith the trigger'sprefetch, the messages it may hold at once (max_messagesof the context), which a route'sprefetchCount={{alternera:source:prefetch}}takes. The host checks the route, starts it and answers a session. The source keeps the member it opened on (its process, port and token) for the session: the deliveries are parked in that member's memory, so every later call goes to it. A member that restarted has another port and token: its calls fail, a receive's assession_lost(the runner opens the source again), a settle's asgonefor each handle (the broker has delivered it again); - receive:
POST /sources/<name>/receive, a long poll of up to the runner's wait; - settle and extend:
POST /sources/<name>/settleand…/extend, every handle answered on its own; - close:
POST /sources/<name>/close: the host gives back what it holds and stops the route.
A {:retry, delay} is kept by the host for the delay, then requeued: the
broker (RabbitMQ) redelivers a requeued message at once, so a member that
dies during the delay has it delivered again sooner.