Overview

Many organisations have to answer one question from data scattered across several systems. A regulated open-banking API is the clearest example: account-information standards require a provider to expose a customer’s current accounts, savings, credit cards, and investment portfolio to an authorised Third-Party Provider (TPP) through a consolidated API. For an institution that grew by acquisition, that data does not live in one system. It lives in a legacy system of record, a modern digital core, a card-processing platform, and possibly a separate investment and custody system. Telecoms operators assembling a customer view across billing, CRM and network inventory, and insurers presenting a portfolio across several policy administration systems, face exactly the same problem. The integration layer that assembles the unified response is a scatter-gather aggregator.

Scatter-gather is one of the original Enterprise Integration Patterns: send one request outbound to N recipients in parallel, collect the N responses, and return a single composed response to the original caller. It is straightforward to describe and genuinely difficult to implement correctly in a regulated context because every trade-off has a regulatory or customer-experience consequence — most obviously the question of what to do when one of the N downstream calls fails or times out within the wall-clock budget.

Start from the contract’s latency budget

Whatever sets the response-time obligation — an open-banking standard, a partner SLA, or your own product target — treat it as a wall-clock budget at the API gateway. For the worked example, assume 3,000ms for account listing and 5,000ms for transaction history. The scatter-gather aggregation layer must complete within a margin of that budget — leaving room for the gateway overhead, TLS handshake, and serialisation. A practical internal target is 2,500ms wall-clock for the aggregation, 300ms for a single-system account query that the cache serves.

When to use it

The scatter-gather pattern earns its complexity cost in one specific situation: the response requires data from multiple independent sources that cannot be queried together, and those sources can be called in parallel to meet a latency budget that sequential calls would miss.

Pattern Use when Do not use when
Scatter-Gather N independent systems; partial result is acceptable; latency budget is tighter than sum of sequential calls Sources are dependent (B needs A’s result); all-or-nothing is required; N = 1
Sequential call chain Each call depends on the prior result; ordering matters for business logic Sources are independent; latency is critical; a slow source should not block others
API composition (BFF) Response needs data from two or three services; client-driven aggregation is acceptable Many sources (>4); a backend aggregation contract is required; the client is a TPP not in your control
Event-driven read model Query volume is high; freshness within seconds is acceptable; Debezium + Kafka pipeline is already in place Real-time freshness is required; data sources cannot produce events; regulatory audit trail per query is needed

For the open-banking example, scatter-gather is the right choice when: the account universe spans multiple systems, the API standard requires a single consolidated response, and the institution cannot afford the 2–4 second latency of sequential calls to its legacy core plus card platform plus digital core. When a pre-built read model fed by CDC is available (from a Debezium pipeline into a Redis or Elasticsearch projection), use that instead — it is simpler and faster. Scatter-gather is the fallback when the read model does not exist or cannot be built within the programme timeline.

Fan-out design

The fan-out side of scatter-gather requires three decisions before writing code: which systems are in scope, what the request schema looks like for each, and whether the fan-out is static (always call all N systems) or dynamic (derive the target list from the customer’s product holding at query time).

Dynamic fan-out is usually the right choice: a customer with only current accounts and a credit card should not trigger a call to the investment platform. Dynamic fan-out reduces downstream load and reduces the chance that a slow or unavailable system delays a response for customers who have no products on that system. The product holding map — which systems hold products for which customers — must be maintained centrally, usually in a party and product registry that the integration layer queries at the start of each Open Banking session.

Timeout budget allocation

The 3,000ms response-time budget is a wall-clock budget that must be allocated across every hop in the response path. Working backwards from the SLA:

  • TLS + gateway overhead: 50ms
  • Product registry lookup: 50ms (served from Redis; no network hop to the legacy core)
  • Scatter-gather wall-clock: 2,500ms (the entire parallel fan-out must complete within this)
  • Response assembly and serialisation: 150ms
  • Total: 2,750ms, leaving 250ms margin against the 3,000ms limit

The 2,500ms budget for the scatter-gather fan-out is the budget for the slowest downstream call that completes within the window. Fast calls (a modern digital core returning in 80ms) return early; slow calls (a legacy core that consistently takes 1,800ms) define the wall clock. Any downstream that does not respond within 2,500ms must be treated as a timeout and handled as a partial result — which means the per-call timeout for each downstream must be set to 2,400ms (100ms less than the fan-out budget, to allow for thread scheduling overhead).

Do not give every downstream the same timeout

Setting a uniform 2,400ms timeout across all downstreams means a fast digital core that returns in 80ms still waits for the 2,400ms window before the caller considers it timed out if it fails. The right design is a per-downstream timeout derived from that system’s p99 latency plus a 50% safety margin, subject to the 2,400ms hard ceiling. A system with a p99 of 200ms gets a 300ms timeout. A legacy core with a p99 of 1,500ms gets a 2,250ms timeout. Configure these per-downstream, measure them in production, and tune quarterly.

IBM ACE implementation

IBM ACE has no single “fan-out” node. It implements scatter-gather with its aggregation nodes — AggregateControl, AggregateRequest and AggregateReply — which correlate asynchronous request/reply branches through IBM MQ, or with the Group nodes — GroupScatter, GroupGather and GroupComplete — which do the same job for asynchronous request nodes such as HTTPAsyncRequest/HTTPAsyncResponse and keep the group state in the integration server rather than on MQ queues. The walk-through below uses the aggregation nodes, because the legacy-core branch is MQ request/reply; the assembly logic is the same with the Group nodes. Check node properties against the IBM documentation for your ACE release.

  1. Product registry lookup (Compute node)

    A Compute or DatabaseRetrieve node queries the product registry for the consented customer and stores the target system codes (LEGACY, DIGITAL, CARD, INVEST) in the LocalEnvironment. The same list is cached against the request so the reply side can work out which systems did not answer.

  2. Start the aggregation (AggregateControl node)

    The AggregateControl node marks the start of an aggregation and carries its Timeout. That property is set in whole seconds, so a 2,400ms ceiling cannot be expressed exactly: set it to 2 seconds and size every branch timeout inside it. If the legacy core’s p99 does not fit inside that window, that is a signal to use the Spring Boot implementation below, where millisecond budgets are natural.

  3. Dynamic fan-out (Compute + RouteToLabel)

    A Compute node propagates one request per system on the target list — via RouteToLabel and Label nodes, or PROPAGATE TO TERMINAL to one output terminal per branch. Because the aggregation counts only the requests actually sent, a customer with no investment holdings never waits for the investment platform.

  4. Per-branch requests (MQOutput + AggregateRequest)

    Each branch builds its request and sends it with an MQOutput node wired to an AggregateRequest node, whose Folder name property (LEGACY, DIGITAL, CARD, INVEST) labels the reply. The legacy-core adapter translates the request to the core’s fixed-length format with DFDL; adapters for REST or SOAP back ends sit behind their own request queues, so every branch looks like MQ request/reply to the aggregation. Each adapter normalises its response to the canonical account schema.

  5. Per-branch timeouts

    Give each adapter its own timeout below the aggregation timeout — the request node’s timeout for HTTP back ends, message expiry plus a bounded reply wait for MQ — and have it reply with a structured error (status: ERROR or TIMEOUT) rather than stay silent. That lets the assembly tell “answered with an error” from “did not answer at all”.

  6. Collect replies (AggregateReply node)

    Replies arrive on the reply queue through an MQInput node and the AggregateReply node correlates them. When every reply is in, it propagates the combined message on its Out terminal; when the AggregateControl timeout expires first, it propagates whatever has arrived on its Timeout terminal. Wire both paths to the assembly — the timeout path through a small Compute node that sets a partial flag — so a slow branch yields a flagged partial response, not an error. Replies that arrive after the timeout leave through the Unknown terminal: log them.

  7. Response assembly (Compute node)

    A final Compute node walks the aggregated reply tree (InputRoot.ComIbmAggregateReplyBody, one folder per branch), copies the accounts from the branches that succeeded, and assembles the API’s JSON response. It appends a partialData flag and the degraded systems when any branch did not return a full result — use the standard’s degraded-response indicator where it defines one, and add one where it does not.

AccountAggregator.esql — assembling the AggregateReply outputesql
-- Reply flow: MQInput (reply queue) -> AggregateReply
--   Out terminal     -> AssembleAggregatedAccounts (every branch answered)
--   Timeout terminal -> MarkPartial -> AssembleAggregatedAccounts (what arrived in time)
CREATE COMPUTE MODULE AssembleAggregatedAccounts
  CREATE FUNCTION Main() RETURNS BOOLEAN
  BEGIN
    -- Each reply sits under a folder named by its AggregateRequest node's
    -- Folder name property: LEGACY, DIGITAL, CARD or INVEST.
    DECLARE partial   BOOLEAN COALESCE(Environment.Variables.AggregationTimedOut, FALSE);
    DECLARE acctIndex INTEGER 1;
    DECLARE reply     REFERENCE TO InputRoot.ComIbmAggregateReplyBody.*[1];

    SET OutputRoot.Properties = InputRoot.Properties;
    CREATE LASTCHILD OF OutputRoot DOMAIN('JSON');
    CREATE FIELD OutputRoot.JSON.Data.accounts IDENTITY (JSON.Array)accounts;
    CREATE FIELD OutputRoot.JSON.Data.meta.respondedSystems IDENTITY (JSON.Array)respondedSystems;

    WHILE LASTMOVE(reply) DO
      IF reply.JSON.Data.status = 'SUCCESS' THEN
        CREATE LASTCHILD OF OutputRoot.JSON.Data.meta.respondedSystems
          NAME 'Item' VALUE FIELDNAME(reply);
        -- Copy the canonical accounts this branch returned
        DECLARE acct REFERENCE TO reply.JSON.Data.accounts.Item[1];
        WHILE LASTMOVE(acct) DO
          SET OutputRoot.JSON.Data.accounts.Item[acctIndex] = acct;
          SET acctIndex = acctIndex + 1;
          MOVE acct NEXTSIBLING REPEAT NAME;
        END WHILE;
      ELSE
        SET partial = TRUE;   -- the branch answered with ERROR or TIMEOUT
      END IF;
      MOVE reply NEXTSIBLING;
    END WHILE;

    -- A branch that never answered has no folder at all: the degraded systems are
    -- the cached target list minus respondedSystems (added by the next node).
    SET OutputRoot.JSON.Data.meta.partialData    = partial;
    SET OutputRoot.JSON.Data.meta.queryTimestamp =
        CAST(CURRENT_TIMESTAMP AS CHARACTER FORMAT 'IU');
    RETURN TRUE;
  END;
END MODULE;

Spring Boot implementation

When the aggregation layer is not built on IBM ACE — common for greenfield Open Banking gateway implementations on OpenShift — Spring Boot 3 with CompletableFuture and VirtualThreads (Java 21) is the idiomatic choice. The CompletableFuture.allOf() and CompletableFuture.anyOf() methods handle fan-out/fan-in; Resilience4j decorates each downstream call with its own circuit breaker and timeout policy.

AccountAggregationService.java — virtual-thread scatter-gatherjava
@Service
public class AccountAggregationService {

    private final ProductRegistryClient registry;
    private final Map<SystemCode, AccountSourceAdapter> adapters;
    private final AggregationCache cache;
    // One shared executor: cheap with virtual threads, but never create one per request
    private final ExecutorService fanOut = Executors.newVirtualThreadPerTaskExecutor();

    public AggregatedAccountResponse aggregate(String consentId, String customerId) {
        var targets = registry.getProductSystems(customerId); // e.g. [LEGACY, DIGITAL, CARD]

        var futures = targets.stream()
            .map(system -> fetchWithTimeout(system, customerId, consentId))
            .toList();

        var all = CompletableFuture.allOf(futures.toArray(new CompletableFuture[0]));

        try {
            all.get(2_400, TimeUnit.MILLISECONDS); // hard ceiling
        } catch (TimeoutException e) {
            // per-call timeouts normally fire first; stragglers are reported as TIMEOUT below
        } catch (InterruptedException e) {
            Thread.currentThread().interrupt();
        } catch (ExecutionException e) {
            // not expected: every branch converts its own failure into a SystemResult
        }

        return assembleResult(targets, futures);
    }

    private CompletableFuture<SystemResult> fetchWithTimeout(
            SystemCode system, String customerId, String consentId) {

        var adapter = adapters.get(system);
        return CompletableFuture
            .supplyAsync(() -> adapter.fetchAccounts(customerId, consentId), fanOut)
            .orTimeout(adapter.getTimeoutMs(), TimeUnit.MILLISECONDS)
            .handle((result, ex) -> ex == null
                ? new SystemResult(system, result, Status.SUCCESS)
                : new SystemResult(system, null,
                    unwrap(ex) instanceof TimeoutException ? Status.TIMEOUT : Status.ERROR));
    }

    private static Throwable unwrap(Throwable ex) {
        return (ex instanceof CompletionException && ex.getCause() != null) ? ex.getCause() : ex;
    }

    private AggregatedAccountResponse assembleResult(
            List<SystemCode> targets,
            List<CompletableFuture<SystemResult>> futures) {

        // Pair futures with targets by index, so a branch that has not finished
        // is still reported against the right system.
        var results = IntStream.range(0, targets.size())
            .mapToObj(i -> futures.get(i).getNow(
                new SystemResult(targets.get(i), null, Status.TIMEOUT)))
            .toList();

        var accounts = results.stream()
            .filter(r -> r.status() == Status.SUCCESS)
            .flatMap(r -> r.accounts().stream())
            .toList();

        var degraded = results.stream()
            .filter(r -> r.status() != Status.SUCCESS)
            .map(r -> r.system().name())
            .toList();

        return new AggregatedAccountResponse(accounts, !degraded.isEmpty(), degraded);
    }
}
Virtual threads change the capacity model

Java 21 virtual threads (Project Loom) eliminate the thread-per-downstream scalability ceiling that made scatter-gather expensive on platform thread pools. Each downstream call runs on its own virtual thread; blocking I/O parks the virtual thread and yields the carrier thread for other work. At 100 concurrent Open Banking sessions each fanning out to 3 systems, you need 300 concurrent I/O calls — trivial for virtual threads, expensive for a fixed platform thread pool of 200. If you are building the aggregation layer on Java 17 or earlier, use a dedicated ForkJoinPool with a parallelism ceiling matched to your downstream concurrency limits.

Partial result handling

The partial result decision is the hardest business call in a scatter-gather implementation, and it must be made explicitly — not defaulted by the engineering team. The choices are:

  • Return available + flag degraded: The response includes accounts from the systems that responded successfully. A meta.partialData: true flag and a meta.degradedSystems array tell the TPP which systems did not respond. Check whether your standard defines its own partial-data indicator, and what it requires during a declared degraded period.
  • Fail the entire request: If any mandatory system (e.g. the primary legacy core) does not respond, return a 503 with a Retry-After header. Use this for systems that hold accounts the customer is likely querying specifically — not a justified default for the investment platform if only 20% of customers have investment accounts.
  • Serve from stale cache: If a fresh partial result is unacceptable but a stale complete result from a prior successful query is acceptable, serve the cache entry and flag its age. This requires a cache TTL policy and a consent-aware cache key (covered in the next section).
Never silently omit accounts

The worst partial-result behaviour is returning an account list that appears complete but is missing accounts from a timed-out system — without any flag to signal the omission. A TPP that shows a customer their “balance” from an incomplete response without indicating the data is partial creates a consumer-harm risk and, on a regulated API, a likely compliance issue — standards that define completeness indicators expect providers to use them. Always surface the partial flag; never return a 200 OK response with silently missing data.

Circuit breaker integration

Each downstream in the scatter-gather must be independently circuit-broken. If the legacy core is in an open circuit state, the fan-out should not even attempt to call it — it should immediately return a CIRCUIT_OPEN status for that branch and let the aggregation proceed without waiting for the legacy-core timeout to expire. While that circuit is open, response time drops from 2,250ms (the legacy-core per-call timeout) to <5ms (the circuit breaker check).

application.yml — Resilience4j circuit breakers per downstreamyaml
resilience4j:
  circuitbreaker:
    instances:
      legacy-core-adapter:
        slidingWindowSize: 20
        failureRateThreshold: 40         # legacy core is fragile: open at 40%
        slowCallRateThreshold: 60
        slowCallDurationThreshold: "1800ms"
        waitDurationInOpenState: "30s"
        permittedNumberOfCallsInHalfOpenState: 3
        automaticTransitionFromOpenToHalfOpenEnabled: true

      digital-core-adapter:
        slidingWindowSize: 20
        failureRateThreshold: 60         # digital core is reliable: open at 60%
        slowCallDurationThreshold: "300ms"
        waitDurationInOpenState: "15s"
        permittedNumberOfCallsInHalfOpenState: 5
        automaticTransitionFromOpenToHalfOpenEnabled: true

      card-adapter:
        slidingWindowSize: 20
        failureRateThreshold: 50
        slowCallDurationThreshold: "500ms"
        waitDurationInOpenState: "20s"
        permittedNumberOfCallsInHalfOpenState: 3
        automaticTransitionFromOpenToHalfOpenEnabled: true

  timelimiter:
    instances:
      legacy-core-adapter:
        timeoutDuration: "2250ms"  # p99 1500ms + 50% margin
      digital-core-adapter:
        timeoutDuration: "300ms"   # p99 200ms + 50% margin
      card-adapter:
        timeoutDuration: "750ms"   # p99 500ms + 50% margin

Response caching

Open Banking account queries have a characteristic usage pattern: a customer opens their finance app, grants consent, and the TPP calls the account listing once per session startup, then periodically in the background. The same aggregated result is requested multiple times in a short window. Caching the assembled result — not individual downstream results — at a 60-second TTL is usually the highest-leverage performance optimisation available: when a TPP polls the same consent several times in a minute, all but the first call are served without a fan-out. Measure the hit rate on your own traffic before relying on it for capacity planning.

Cache key design for Open Banking must incorporate the consent ID, not just the customer ID. A single customer may have multiple active consents from different TPPs, each with a different account scope. The cache key must be consent:{consentId}:accounts. The TTL must be bounded by the consent expiry — a consent expiring in 30 seconds must not be served from a 60-second-old cache entry that pre-dates the expiry.

Partial results should be cached with a flag and a shorter TTL. If the legacy core was unreachable during the aggregation and you cached a partial result, the next request should re-attempt the fan-out sooner than it would for a complete result. Use a 15-second TTL for partial results versus 60 seconds for complete.

Regulated-API obligations

Open-banking standards — and regulated partner APIs generally — impose obligations on aggregation-layer behaviour that are not obvious from reading the API specification alone:

  • Consent scope enforcement at the aggregator: The aggregation layer must enforce the account scope in the consent grant. If a TPP’s consent covers only current accounts, the aggregator must not fan out to the card processor even if the customer has a card. This requires the product registry lookup to intersect the customer’s product holding with the consented account types before constructing the target list.
  • Response staleness disclosure: When serving a cached result, the response must include a meta.dataRetrievedAt field with the timestamp of the last live fetch. Where the standard does not mandate a maximum staleness, assume ambiguous cases will be interpreted against the provider; keep staleness within the cache TTL and surface it in the response.
  • Audit log per aggregation call: Each fan-out must be logged with: the consent ID, customer pseudonym, target system list, per-system status and latency, and whether the response was partial. This log is the evidence trail for a regulatory inspection of an incident.
  • Rate limit enforcement: Open-banking regimes commonly cap how often a TPP may call without the customer present. Under the EU’s PSD2 regulatory technical standards on strong customer authentication and secure communication (Commission Delegated Regulation (EU) 2018/389, Article 36(5)), an account information service provider may access account data without the customer actively requesting it no more than four times in a 24-hour period, unless a higher frequency is agreed with the account provider with the customer’s consent; the UK’s version of the RTS carries the same rule. Count these accesses where the consent context lives — in the aggregation or consent layer, per consent and account — rather than only in gateway counters keyed by client, and decide explicitly whether a cache hit counts as an access.
Consent scope may use resource IDs, not types

Many open-banking consent models reference specific account resource IDs (provider-assigned account identifiers) rather than account types. This means your product registry lookup must map resource IDs to systems — not types to systems — and your aggregation must only fan out to systems that hold at least one resource ID from the consent grant. A consent for account resource acc-7f3e91 (a current account held on the legacy core) must not trigger a card-processor call, even though the customer has cards. The registry design must support per-resource-ID system mapping, not just per-product-type.

Performance & scalability

Scatter-gather is I/O-bound, not CPU-bound. The scalability ceiling is the number of concurrent downstream connections you can hold open, which is a function of connection pool sizes, the downstream systems’ own concurrency limits, and the number of concurrent Open Banking sessions.

At 500 concurrent Open Banking sessions fanning out to 3 systems each, the aggregation layer needs to sustain 1,500 concurrent outbound connections. Each downstream must have a connection pool sized to absorb that load without queueing. For the legacy core, 1,500 concurrent connections is likely above its capacity — this is the most common scalability limit discovered during load testing. The remediation is to introduce a request queue at the legacy-core adapter with a maximum queue depth, circuit break when the queue fills, and serve partial results from the other two systems. The legacy-core adapter becomes the pacing element for the entire aggregation; size its connection pool and queue depth in coordination with the team that runs it.

Component Key sizing parameter Typical value for 500 concurrent sessions
Legacy-core adapter connection pool Max concurrent legacy-core connections 150–200 (core-limited; queue remainder)
Digital core adapter HTTP connection pool per pod 400 (REST API; modern platform)
Card adapter connection pool SOAP/HTTP connections 250 (legacy constraint from card processor)
Redis cache Operations per second 5,000 reads + 1,000 writes (well within Redis single-node capacity)
Spring Boot pods (OpenShift) Pods at peak 4–6 pods at 100 sessions/pod HPA target

What production tells you

Three things appear in almost every scatter-gather production deployment that engineering teams do not predict during design.

The slowest downstream defines your p99, not your average. If the legacy core takes 1,800ms p99 on working days during peak hours, your scatter-gather response time p99 is 1,800ms regardless of how fast the other three systems are. Optimising the digital core from 100ms to 80ms makes no measurable difference to the customer. The only optimisation that matters for latency is reducing the legacy core’s response time — which usually requires caching or indexing changes on the legacy side, not changes to the aggregation layer.

Consent-scope enforcement bugs produce phantom data. The most common production incident after go-live is a TPP receiving account data outside the consented scope — not because of a security breach, but because the product registry lookup was incorrect and fanned out to a system that holds an account the consent does not cover. The result is a customer complaint that the finance app shows an account they did not expect. This is a consent enforcement bug, not a data breach, but on a regulated API it can still trigger a regulatory incident report. Test consent scope enforcement explicitly with accounts that partially overlap the consented scope; do not test only with fully-consented customers.

The partial-result flag is the most useful operational signal you have. When the legacy-core circuit breaker opens during a maintenance window, the partial-result flag in your logs tells you exactly which sessions were affected and which TPPs need to be notified. If you did not build the partial flag into your audit log at launch, you will reconstruct the blast radius of every legacy-core incident from raw logs, manually, while the incident is open. Build the flag; log it; alert on a threshold (e.g. more than 15% of sessions returning partial in any 5-minute window).