ArchitectMind
  1. Home
  2. Java Ecosystem
  3. Book 6 · Databases, APIs & Integration
  4. Volume VII
  5. Why Systems Integrate
Book 6 · Volume VII — Enterprise Integration & Messaging · Topic 1.1

Why Systems Integrate

Data exchange, business processes, legacy integration and external services

15 min readStage 3 · Systems8 interview questions
Chapter
Chapter 1 — Enterprise Integration Fundamentals
Prerequisites
Volume VI (APIs)
You will be able to
Identify the business and technical drivers for integration in an enterprise landscape, classify integration needs as data exchange, process integration, legacy access or external service use, recognise their typical constraints, and map each need to candidate integration styles and patterns
Covers
Data exchange; Business processes; Legacy integration; External services
On this page
  1. 1. Concept / Definition
  2. 2. Why It Exists
  3. 3. Core Concepts
  4. 4. How It Works Internally — Integration Needs Inventory
  5. 4A. Deep Dive — Integration as a Cost Centre
  6. 5. APIs / Features / Syntax
  7. 6. Practical Examples
  8. 7. Common Problems & Mistakes
  9. 8. Performance & Production Considerations
  10. 9. Architecture & Design Considerations
  11. 10. Interview Questions & Answers

1Concept / Definition

Enterprise integration connects independently built applications so they can share data and participate in shared business processes — without merging them into one system.

Why an enterprise must integrate
Figure 1 — Why an enterprise must integrate
TOC driverDefinitionExample
Data exchangeMaking data owned by one system available to othersProduct catalogue from ERP to e-commerce
Business processesCoordinating steps of one process across systemsOrder-to-cash: shop → payment → WMS → ERP
Legacy integrationConnecting old systems whose interfaces predate modern standardsLoyalty points on a mainframe
External servicesUsing capabilities provided by other organisationsPayment gateways, carriers, tax services
Table 1 — The four TOC drivers

2Why It Exists

Enterprises buy best-of-breed packages, build custom applications, acquire companies and adopt SaaS. Each system owns part of the truth. A single customer journey — browse, order, pay, ship, invoice, support — touches half a dozen of them. Without integration, humans re-key data, processes stall and reports disagree.

Integration drivers (TOC)
Figure 2 — Integration drivers (TOC)

3Core Concepts

3.1 Data exchange

Data exchange aspectQuestions
OwnershipWhich system is the source of truth for customer, product, price?
DirectionOne-way publish or bidirectional sync?
LatencyNightly? Minutes? Seconds?
VolumeHundreds of records or millions?
ShapeFull snapshots or change events (CDC)?
QualityValidation, deduplication, reference data mapping
Table 2 — Designing data exchange

3.2 Business processes

Order-to-cash across systems
Figure 3 — Order-to-cash across systems
Process integration aspectConcern
SequencingPayment before fulfilment
StateWhere is order 5001 now?
FailuresPayment ok but warehouse down — compensate?
Coordination styleOrchestration vs choreography (Chapter 7)
ConsistencyNo distributed transactions → sagas (Volume VIII)
Table 3 — Process integration raises harder questions than data exchange

3.3 Legacy integration

Legacy integration
Figure 4 — Legacy integration
Legacy techniqueWhen
Messaging bridge (IBM MQ)Mainframe already speaks MQ
Screen/terminal adaptersLast resort for green-screen apps
Database CDC (Debezium)Emit changes without touching code
File dropsBatch-oriented systems
API façade (strangler fig)Gradual replacement
Table 4 — Unlocking legacy systems

3.4 External services

External services
Figure 5 — External services
External integration concernDesign response
Different availability and SLAsTimeouts, retries, circuit breakers, queues
Contract changes by providerAnti-corruption layer, contract monitoring
SecurityOAuth, mTLS, secrets management, IP allow-lists
Asynchronous resultsWebhooks, polling, callbacks
Cost per callCaching, batching, rate limiting
Table 5 — Integrating beyond your control

4How It Works Internally — Integration Needs Inventory

IntegrationDriverDirectionLatencyVolumeCriticality
Products ERP → shopData exchangeOne-way15 min50k itemsMedium
Order → paymentExternal serviceRequest/reply< 2 s200/minCritical
Order → WMSBusiness processCommand< 1 min200/minCritical
Shipment → ERP invoiceBusiness processEvent< 15 min200/minHigh
Loyalty → mainframeLegacyBatchNightly10k/dayMedium
Table 6 — An inventory makes integration architecture visible
Driver → typical integration style
Figure 6 — Driver → typical integration style

4ADeep Dive — Integration as a Cost Centre

Where enterprise IT effort goes (illustrative)
Figure 7 — Where enterprise IT effort goes (illustrative)
Hidden integration costMitigation
Duplicated mapping logicCanonical models, shared schemas
Undocumented interfacesIntegration catalogue, AsyncAPI/OpenAPI
Fragile scripts and cron jobsManaged integration platforms, monitoring
Error handling by emailDead-letter queues, replay tooling (Chapter 5)
Tribal knowledgeOwnership per integration
Table 7 — Making integration cost visible

5APIs / Features / Syntax

NeedJava ecosystem tools
Data exchangeSpring Batch, CDC (Debezium), Kafka Connect
Process integrationSpring Integration, Camel, workflow engines (Temporal, Camunda)
LegacyIBM MQ JMS client, Camel mainframe components, CDC
External servicesSpring RestClient, webhooks with Spring MVC, Resilience4j
DocumentationAsyncAPI (events), OpenAPI (APIs)
Table 8 — Toolkit per driver

6Practical Examples

6.1 Re-keying orders

A distributor's sales team re-typed web orders into the ERP twice daily; errors caused 3% wrong shipments. An order integration via messaging removed manual entry and cut order-to-ship time from 1 day to 2 hours.

6.2 Legacy loyalty

Loyalty points lived on a mainframe updated nightly by files. Customers saw stale balances in the app. Debezium CDC on the mainframe's DB2 replica published point changes to Kafka within seconds, without modifying COBOL programs.

6.3 Worked example — source-of-truth matrix

Scenario. A retailer's shop, warehouse system, ERP and CRM all held product, price, customer and stock data. When figures disagreed, nobody could say which system was right, and every fix created a new inconsistency somewhere else.

EntitySource of truthConsumers
Product masterERPShop, WMS, search
PricePricing serviceShop, POS
Customer profileCRMShop, billing, support
Stock levelWMSShop, ERP
OrderOrder serviceWMS, ERP, analytics
Table 9 — Integration starts with ownership

What it shows. The matrix names exactly one source of truth for each entity and lists the systems that consume copies. Product master data comes from the ERP; prices from the pricing service; customer profiles from the CRM; stock levels from the warehouse management system; and orders from the order service. Every integration then has a clear direction: data flows from the source of truth to consumers, and consumers never change their copy and send it back. Disagreements are resolved by checking the source, not by debate.

Takeaway. Start integration work by agreeing ownership, not technology. A source-of-truth matrix is quick to produce, removes most arguments, and determines the direction of every data flow.

6.4 Worked example — integration contract card

Scenario. An integration between the order service and the warehouse system failed silently over a weekend. On Monday, nobody knew who owned it, what delivery time was promised or how to replay the lost messages.

FieldContent
NameOrderPlaced → WMS
DriverBusiness process
StyleMessaging (Kafka topic orders.v1)
OwnerOrders team (producer), WMS team (consumer)
SLAp99 < 60 s end-to-end
Error handlingDLQ orders.v1.wms.dlq, replay runbook
Table 10 — Document each integration explicitly

What it shows. An integration contract card documents each integration in one place: its name and business driver, the style and technology, here a Kafka topic orders.v1, the owners on both sides, the service level, p99 under 60 seconds end to end, and error handling, a dead-letter topic with a replay runbook. With the card in place, on-call engineers know whom to call, which alerts should fire when latency exceeds the SLA, and how to recover lost messages.

Takeaway. Treat every integration as a product with an owner, an SLA and a runbook. A one-page contract card per integration is cheap to write and pays for itself in the first incident.

6.5 Worked example — external payment integration

Scenario. ShopNow integrated a payment service provider for cards and UPI. The team expected one REST API, but found that a single payment involved several different integration styles.

StepMechanism
Create paymentREST call with idempotency key
Customer authentication (3DS/UPI)Redirect/collect flow
ResultWebhook (signed) + reconciliation job
Settlement filesDaily SFTP
Table 11 — One external service, three integration styles

What it shows. Creating a payment is a synchronous REST call that carries an idempotency key, so retries never create duplicate payments. Customer authentication, such as 3-D Secure or a UPI collect request, happens through a redirect or app flow outside ShopNow's control. The final result arrives asynchronously as a signed webhook, backed by a reconciliation job that queries the provider for any payments whose webhooks were missed. Settlement data arrives as daily files over SFTP for the finance team.

Takeaway. External services often combine several integration styles. Design for each one explicitly, including idempotency, signature verification, reconciliation for missed callbacks and file processing, rather than assuming a single synchronous API.

6.6 Worked example — process view vs data view

Scenario. In a design workshop for order fulfilment, the data architects drew which systems held which data, while the business analysts drew the steps from checkout to delivery. Each group thought the other had missed the point.

ViewQuestion answered
Data viewWho owns and who needs each entity?
Process viewWhich steps happen in which system, in what order, with what failure handling?
Table 12 — Architects need both

What it shows. Both views are needed and answer different questions. The data view shows ownership and flows: who masters orders, stock and customers, and who holds copies. The process view shows behaviour over time: which system performs each step, in what order, what happens when a step fails, and who compensates. An integration design that has only the data view misses timing and failure handling; one with only the process view misses ownership and creates conflicting copies of data.

Takeaway. Produce both a data view and a process view for significant integrations, and check them against each other. Gaps between them are where integration failures usually hide.

6.7 Worked example — latency requirements drive style

Scenario. A team planned to integrate everything with events because events were the company standard. For some flows this was ideal; for others it was either too slow or unnecessarily complex.

RequirementStyle
Stock visible to shop within 5 sEvents
Accounting postings by next morningBatch file or event batch
Fraud check before order confirmationSynchronous API
Table 13 — Timeliness is a primary discriminator

What it shows. How soon the receiver needs the information is the main factor in choosing an integration style. Stock levels must appear in the shop within five seconds, which suits events. Accounting postings are needed by the next morning, so a nightly batch file or batched events are simpler and cheaper. A fraud check must complete before the order is confirmed, because its result decides the next step, so it must be a synchronous API call with a timeout and fallback.

Takeaway. Ask "how fresh must the data be, and does the caller wait for the answer?" before choosing a style. Different flows in the same business process often need different styles.

6.8 Worked example — anti-corruption layer for SaaS CRM

Scenario. ShopNow adopted a SaaS CRM. Within months, CRM field names with suffixes like __c, CRM-specific loyalty codes and nullable fields had spread through the order and marketing code bases, and every CRM change broke something.

JAVA
@Component
class CrmCustomerTranslator {  // keeps CRM model out of our domain
    Customer toDomain(SalesforceContact c) {
        return new Customer(
                CustomerId.of(c.externalId__c()),
                c.firstName() + " " + c.lastName(),
                Tier.valueOf(c.loyaltyTier__c().toUpperCase()));
    }
}

What it shows. An anti-corruption layer is a translation component at the boundary that converts the external model into the domain's own model. Here, CrmCustomerTranslator turns a SalesforceContact into a domain Customer, mapping the external ID to a CustomerId value object, combining names and converting the loyalty tier text into the domain's Tier enum. Only this class knows the CRM's model; the rest of the code works with Customer. When the CRM changes, only the translator changes.

Takeaway. Never let an external or legacy model leak into your domain. Put translation at the boundary, test it thoroughly with real sample data, and treat changes in the external system as changes to one class.

6.9 Worked example — M&A integration

Scenario. ShopNow acquired a regional retailer with its own ERP, customer data and warehouses. The board wanted combined reporting immediately and full integration within a year.

PhaseIntegration approach
Day 1File exchanges and reports between both ERPs
Month 3Shared customer master via events
Year 1Migrate acquired company onto group platforms
Table 14 — Integration enables business change

What it shows. The integration was phased to deliver value at each stage. On day one, file exchanges and reports between the two ERPs gave the board combined figures without changing either system. By month three, a shared customer master distributed through events let both companies recognise common customers. By year one, the acquired company migrated onto the group's platforms, retiring its ERP. Each phase used the simplest integration style that met that phase's needs.

Takeaway. Integration is a business enabler, so plan it in phases tied to business milestones. Start with low-risk, quick integrations and move to deeper consolidation once ownership and target platforms are agreed.

6.10 Worked example — integration catalogue fields

Scenario. An enterprise architect inherited a landscape of about 120 integrations documented in scattered wiki pages, many out of date. During incidents, nobody could find who owned an integration or how it worked.

FieldWhy
Systems & ownersAccountability
Style & technologyOperability
Data classificationSecurity/compliance
Volumes & SLAsCapacity
Runbooks & DLQsIncident response
Table 15 — Minimum metadata per integration

What it shows. The minimum metadata in the table turns a list into an operational tool. Systems and owners give accountability; style and technology tell operators how to monitor and troubleshoot; data classification drives security and compliance reviews; volumes and SLAs support capacity planning and alerting; and runbooks and dead-letter queues support incident response. Stored in a searchable catalogue, ideally generated from code and configuration where possible, it becomes the first place engineers look.

Takeaway. Maintain an integration catalogue with a small, mandatory set of fields, and keep it current by making catalogue updates part of the definition of done for any integration change.

6.11 Worked example — CDC for data exchange

Scenario. The legacy order database had no events, and its application could not be changed safely. Several new services needed to react to new and updated orders in near real time.

JSON
{ "name": "orders-cdc",
  "config": { "connector.class": "io.debezium.connector.postgresql.PostgresConnector",
              "database.hostname": "orders-db", "table.include.list": "public.orders",
              "topic.prefix": "cdc" } }

What it shows. Change data capture reads the database's transaction log and turns committed row changes into events, without touching the application. The Debezium PostgreSQL connector configuration shown points at the orders database, includes only the public.orders table and publishes changes to Kafka topics prefixed with cdc. Consumers receive inserts, updates and deletes within seconds. Because CDC exposes table structure, a small transformation step usually maps raw row changes into proper business events before other teams consume them.

Takeaway. Use CDC to integrate systems you cannot change, but do not publish raw table changes as a long-term contract. Translate them into business events, so consumers are not coupled to the legacy schema.

6.12 Worked example — prioritising integration work

Scenario. The integration team had a backlog of twelve requested integrations and capacity for three this quarter. Every requester claimed theirs was the most urgent.

IntegrationBusiness valueRisk todayPriority
Order → WMS (manual)HighHigh errors1
Price sync (nightly)MediumStale prices2
HR → IAM provisioningMediumSecurity gaps2
BI extractLowLow3
Table 16 — Integration roadmap by value and risk

What it shows. Scoring each integration by business value and current risk made the choice transparent. Orders still entered manually into the warehouse system had high value and frequent costly errors, so it came first. The nightly price sync, which caused stale prices, and HR-to-identity provisioning, which left security gaps when staff left, came next. A BI extract with low value and low risk could wait. The scores were shared with stakeholders, which ended most debates.

Takeaway. Prioritise integration work by business value and risk, and make the scoring visible. Manual processes with high error rates and security gaps usually justify the earliest investment.

6.13 Worked example — publishing a business event for data exchange

Scenario. The catalog service needed to notify search, pricing and the shop whenever a product changed. An earlier version published events inside the database transaction, and when the transaction rolled back, consumers had already received events for changes that never happened.

JAVA
@Service
class ProductPublisher {
    private final KafkaTemplate<String, ProductChanged> kafka;
 
    @TransactionalEventListener(phase = TransactionPhase.AFTER_COMMIT)
    void on(ProductUpdated e) {
        var event = new ProductChanged(e.sku(), e.name(), e.price(),
                                       e.version(), Instant.now());
        // key = sku → per-product order
        kafka.send("catalog.products.v1", e.sku(), event);
    }
}
Design choiceReason
Publish after commitNo events for rolled-back changes
Key by SKUConsumers see changes per product in order
Version fieldConsumers ignore stale updates
Table 17 — Data exchange via events (outbox in Volume VIII makes this fully reliable)

What it shows. The ProductPublisher listens with @TransactionalEventListener in the AFTER_COMMIT phase, so the Kafka event is sent only after the database transaction has committed. The event is a dedicated ProductChanged record with the SKU, name, price, a version number and a timestamp, not the JPA entity. Using the SKU as the message key keeps all events for one product in the same Kafka partition, so consumers see them in order. If the send itself fails, a transactional outbox is the more robust pattern.

Takeaway. Publish integration events only for committed changes, use dedicated event types as the contract, and choose message keys that preserve the ordering consumers need. For guaranteed delivery, use the outbox pattern.

6.14 Worked example — webhook receiver for an external service

Scenario. ShopNow's payment provider reports final payment results by calling a webhook. During a sale, slow processing in the webhook handler caused the provider to time out and retry, creating duplicate processing and alarming partners.

JAVA
@PostMapping("/webhooks/payments")
ResponseEntity<Void> paymentEvent(@RequestHeader("X-Signature") String sig,
                                  @RequestBody byte[] body) {
    if (!signatures.valid(sig, body)) return ResponseEntity.status(401).build();
    inbox.store(body);  // persist first, process async
    return ResponseEntity.accepted().build();                   // 202 quickly
}
RuleReason
Verify signatureAuthenticity
Store then acknowledge fastProvider timeouts and retries
Process asynchronously, idempotentlyDuplicates are normal
Table 18 — External services push results asynchronously

What it shows. The receiver does only three things synchronously: it verifies the provider's signature over the raw body, rejecting forged calls with 401; it stores the raw payload in an inbox table; and it returns 202 Accepted immediately. A separate process then handles inbox entries asynchronously and idempotently, using the provider's event ID to ignore duplicates. The provider sees fast, reliable acknowledgements, and processing problems no longer cause retries.

Takeaway. Webhook endpoints should verify, persist and acknowledge quickly, then process asynchronously and idempotently. Back them with reconciliation, because some webhooks will always be lost.

7Common Problems & Mistakes

  • No clear source of truth per entity.
  • Treating process integration as data copying.
  • Direct coupling to legacy internals.
  • Ignoring external service failure modes.
  • Undocumented integrations with no owner.
  • Choosing technology before understanding needs.

8Performance & Production Considerations

AspectGuideline
InventoryCatalogue all integrations with owners
LatencyRequirements per integration
VolumeCapacity planning per flow
ErrorsDLQs, replay, alerts
ExternalResilience patterns, contract monitoring
Table 19 — Operational guidelines

9Architecture & Design Considerations

  • Start from business drivers, then choose styles.
  • Define ownership and sources of truth.
  • Protect domains with anti-corruption layers.
  • Treat integration as a first-class architecture concern with its own roadmap.

10Interview Questions & Answers

Q1L1 · BasicConcept

Why do enterprises need integration?

No single system can run a whole business. Enterprises use many applications, such as ERP, CRM, e-commerce, warehouse, finance and HR systems, often from different vendors and eras, each specialised for one part of the business. Business information and processes cross these boundaries: an order placed in the shop must reach the warehouse, finance and customer service. Integration lets systems share data from its source of truth and coordinate steps in a process, so people do not re-enter data by hand. Done well, it keeps data consistent and processes fast; done badly, it creates fragile point-to-point links that are hard to change.

Q2L1 · BasicConcept

Name four integration drivers.

Data exchange shares information from the system that owns it with systems that need copies, such as product data from the ERP to the shop. Business processes coordinate steps that span several systems, such as order fulfilment from payment to shipping, including failure handling. Legacy integration connects older systems that cannot easily be changed, using adapters, files or change data capture, often as part of modernisation. External services connect to systems outside the organisation, such as payment providers, logistics partners or SaaS products, which bring their own contracts, security and availability. Identifying the driver helps choose the right integration style and ownership.

Q3L2 · IntermediateConcept

What distinguishes process integration from data exchange?

Data exchange moves information from a source of truth to consumers; each consumer decides independently what to do with it, and there is no shared notion of a process. Process integration coordinates a sequence of steps across systems, such as reserve stock, take payment and then ship, where order matters, state must be tracked and failures need compensation or retries. Process integration therefore needs orchestration or choreography, correlation IDs, timeouts and monitoring of in-flight processes. Treating a process as simple data exchange is a common cause of lost orders and inconsistent states.

Q4L2 · IntermediateDesign

How can legacy systems be integrated without changing them?

When a legacy system cannot be modified, integrate around it. Adapters wrap its existing interfaces, such as database procedures, screens or APIs, and expose them in a modern form. Messaging bridges connect its existing message queues to newer platforms. File interfaces, such as scheduled exports and imports, remain simple and robust for batch flows. Change data capture reads the database's transaction log and publishes row changes as events without touching application code. These approaches let new systems interact with legacy ones safely and are often the first step of a Strangler Fig migration.

Q5L3 · Senior EngineerConcept

What special concerns arise with external services?

External services sit outside your control, so several concerns become prominent. Their availability and latency differ from yours, so you need timeouts, retries and fallbacks. Their contracts can change on their schedule, so you need version monitoring and an anti-corruption layer. Security is stricter: credentials, request signing, data classification and legal agreements. Results often arrive asynchronously through webhooks, which require signature verification, idempotent processing and reconciliation for missed calls. Many services also charge per call, so caching and batching affect cost. Rate limits and sandbox environments must be considered in testing.

Q6L3 · Senior EngineerConcept

What is an anti-corruption layer?

An anti-corruption layer is a translation component placed at the boundary with a system whose model you do not control, such as a legacy application or a SaaS product. It converts the external model, with its field names, codes and quirks, into your own domain model, and converts your requests back. Only the anti-corruption layer knows the external model, so the rest of your code stays clean and expressed in your domain language. When the external system changes or is replaced, only the translation layer changes. The term comes from domain-driven design.

Q7L4 · Technical ArchitectDesign

What should an integration catalogue contain?

An integration catalogue should list, for each integration, the systems involved and the owning teams on both sides; the business driver and the integration style and technology, such as REST, Kafka topic or file transfer; the data exchanged and its classification for security and compliance; expected volumes and service levels, such as latency and availability; error handling, including dead-letter queues and retry policies; monitoring and alerts; and runbooks for common incidents. It should be searchable, kept current as part of every integration change, and generated from configuration or code where possible, so it stays trustworthy.

Q8L5 · Solution ArchitectScenario

How would you start an integration strategy for a landscape of 40 applications?

Begin with an inventory of all existing integrations, their sources of truth and owners, often discovered from network flows, middleware configuration and interviews. Classify each by driver, style and requirements such as latency, volume and criticality. Identify the riskiest areas, such as fragile point-to-point links, shared databases, manual steps and integrations without owners. Then define target integration styles and platforms, for example APIs through a gateway, an event backbone and managed file transfer, with standards for contracts and security. Prioritise changes by business value and risk, and govern new integrations through a catalogue and design reviews.

Test your knowledge on this topic →Flashcards from this topic's 8 questions, filtered by level and type.

Free question pack

Get 100 free Core Java interview questions

Subscribe for the Book 1 question pack (PDF, every answer explained) and new tutorials once a week. No spam, unsubscribe anytime. What is in the pack?

Almost done! Check your inbox and click the confirmation link. Your download link arrives as soon as you confirm.