Sub topic 12
When middleware is the better choice
This chapter assumes you know Salesforce objects and records, REST and JSON, and what an integration between two systems is. It also assumes you have seen the native options: Flow, Apex callouts, Named Credentials, Platform Events, and the platform APIs. Here you learn the signals that point to middleware, such as MuleSoft, as the better fit.
The core idea
Native tools work well when one Salesforce org talks to one or two systems in a simple way. Middleware earns its cost when the integration needs capabilities that Salesforce does not provide, or when the number of connections makes direct links hard to manage. No single signal decides the question. Look for several signals together.
Signals that middleware fits
Many systems, many consumers
If Salesforce, an ERP, a billing tool, a data warehouse, and a mobile app all need the same customer data, direct links multiply. Each new system adds connections, and each connection carries its own credentials, mapping, and error handling. A middleware layer lets each system connect once. Reusable APIs then serve every consumer.
Heavy or shared transformation
Mapping fields between two systems is easy in Apex. It becomes costly when many systems use different formats such as XML, SOAP, flat files, or EDI. The same mapping then repeats in several places. Middleware centralizes it, as in this DataWeave example:
%dw 2.0
output application/json
---
payload map (customer) -> {
Name: customer.company_name,
BillingCity: customer.address.city,
External_Id__c: customer.id
}When a source system changes its format, you fix one mapping instead of several Apex classes and Flows.
Orchestration across systems
Suppose one business event must update an ERP, call a payment service, wait for a result, and then update Salesforce. Doing this inside a Salesforce transaction means you carry the call sequence, the compensation logic, and the callout limits. Middleware can run the sequence outside Salesforce and report only the outcome.
Reliability requirements
Salesforce callouts are synchronous and limited by governor limits. Middleware adds durable queues, automatic retries with backoff, dead-letter handling, and idempotent processing. Choose it when losing or duplicating a message has real cost, such as in payments or order fulfillment.
Limits pressure
If an integration regularly approaches API request limits, callout limits, or timeouts, moving the work to a layer that batches, caches, and throttles can relieve the pressure. Check the limits first. Do not assume they are the problem.
Security, governance, and monitoring
Regulated environments often need central policy enforcement, such as authentication, rate limiting, and audit trails. They also need one place to see every integration. Middleware gives you an API gateway and a monitoring view across systems. Native tools give you per-org logs only.
Protocol and legacy mediation
Salesforce speaks REST, SOAP, and events well. Mainframes, SFTP drops, JMS queues, and custom protocols need an adapter, and middleware connectors supply one.
Summary table
| Signal | Native tools | Middleware |
|---|---|---|
| Two systems, simple request-reply | Good fit | Often excessive |
| Five or more connected systems | Becomes tangled | Good fit |
| Shared mapping across systems | Duplicated | Centralized |
| Multi-step orchestration | Strained by limits | Good fit |
| Guaranteed delivery needed | Limited | Good fit |
| Legacy protocols | Poor fit | Good fit |
Decision flow
Common errors
- Choosing middleware because it is the standard tool, with no signal from the list above.
- Ignoring the cost of ownership. Middleware needs skills, licenses, and operations, which the next chapter covers.
- Treating one signal as decisive. A single complex mapping rarely justifies a platform.
Exercise
A company needs Salesforce to fetch one order status from a single ERP using REST when a user opens a record. No other system is involved. Which signals favor middleware here?
Show answer
None do. This is one simple request-reply with one system, so a native Apex callout through a Named Credential is enough. Reconsider if more consumers, mappings, or reliability needs appear.
Exercise
An order event must update an ERP, charge a payment service, and update Salesforce, and no order may be lost or charged twice. Which signals apply, and why?
Show answer
Orchestration across systems, because several calls must run in sequence. Reliability, because guaranteed delivery and idempotent processing are required. Both point to middleware.