Connecting Salesforce to an enterprise landscape requires more than just making API calls. Choosing the wrong communication pattern can lead to hit governor limits, performance bottlenecks, and brittle point-to-point connections. Understanding the standard integration patterns allows you to build scalable, secure, and maintainable systems.
1. Point-to-Point vs. Hub-and-Spoke (Middleware)
- Point-to-Point Integration: Connects Salesforce directly to a single target application using REST, SOAP, or custom Apex callouts. While quick to set up for 1-to-1 connections, it becomes unmanageable and tightly coupled as the number of systems grows.
- Hub-and-Spoke (Middleware / ESB): Routes traffic through a centralized integration platform like MuleSoft, Boomi, or Workato. The middleware handles authentication, transformation, orchestration, and error logging, keeping Salesforce decoupled from external changes.
2. Remote Process Invocation (Request-Reply & Fire-and-Forget)
Used when Salesforce initiates an action in an external system and optionally waits for a response:
- Request-Reply (Synchronous): Salesforce triggers an external process (e.g., real-time tax calculation or payment verification) and blocks execution until it receives the result. Implemented via Apex HTTP callouts or Flow HTTP Callouts configured with
Named Credentials. - Fire-and-Forget (Asynchronous): Salesforce hands off a payload to an external system and immediately frees up resources without waiting for process completion. Handled via Queueable Apex, Platform Events, or Change Data Capture (CDC).
Offloading a long-running callout to prevent transaction timeout and avoid blocking the UI:
public class AsyncOrderProcessor implements Queueable, Database.AllowsCallouts {
private Id orderId;
public AsyncOrderProcessor(Id orderId) {
this.orderId = orderId;
}
public void execute(QueueableContext context) {
HttpRequest req = new HttpRequest();
req.setEndpoint('callout:ERP_Named_Credential/v1/orders');
req.setMethod('POST');
req.setHeader('Content-Type', 'application/json');
req.setBody(JSON.serialize(new Map<String, Object>{ 'orderId' => orderId }));
Http http = new Http();
HttpResponse res = http.send(req);
// Process response or log integration status asynchronously
}
}
3. Real-Time Event-Driven Architecture (Publish / Subscribe)
Event-driven integrations decouple producers from consumers. Salesforce publishes an event when a business milestone occurs, and multiple external consumers subscribe to the stream:
- Platform Events: Define custom event schemas published via Apex, Flows, or the standard REST API. External systems listen via the high-throughput Salesforce Pub/Sub API (gRPC).
- Change Data Capture (CDC): Automatically publishes events whenever standard or custom records are created, updated, deleted, or undeleted, eliminating the need to write custom trigger logic for data sync.
- Event Relays: Natively streams Salesforce Platform Events directly into cloud message buses like AWS EventBridge without middleware code.
4. Batch Data Synchronization
Designed for transferring massive datasets without hitting API call limits or degrading org performance during business hours:
- Bulk API 2.0: Uses an asynchronous engine optimized for processing hundreds of thousands to millions of records. Uploads CSV data directly to Salesforce-managed parallel queues.
- ETL / ELT Pipelines: Nightly data warehouse syncs and business intelligence extractions orchestrated by tools like Informatica, Fivetran, or Snowflake connectors.
5. Data Virtualization (Salesforce Connect)
Allows users and automation to view, search, and modify data residing in external legacy databases without storing a single byte in Salesforce standard data storage.
- External Objects (
__x): Appear just like custom objects in Salesforce (supporting tabs, page layouts, lookups, and SOQL) but fetch data on the fly via OData 2.0/4.0 adapters. - Zero Data Replication: Ensures real-time accuracy, avoids dual-system synchronization issues, and saves Salesforce storage costs.
- Request-Reply: Synchronous callouts via Named Credentials (best for immediate calculations and payment checks).
- Fire-and-Forget: Platform Events / Queueable Apex (best for decoupling downstream system notifications).
- Data Virtualization: Salesforce Connect & OData (best for large historical data stored in ERP/Postgres).
- Batch Sync: Bulk API 2.0 (best for scheduled record migrations exceeding 10k+ rows).
6. Common Architecture Pitfalls & Best Practices
Executing a synchronous DML operation (e.g.,
insert record;) before an HTTP callout in the same Apex transaction triggers a fatal runtime exception. Always execute callouts before DML or delegate the callout to a Queueable job.
- Always use Named Credentials: Centralizes authentication, manages token refreshes automatically, and prevents hardcoded URLs or secrets in code.
- Design for Idempotency: Ensure external systems provide unique transaction keys or leverage Salesforce External IDs to avoid duplicate record creation during network retries.
- Monitor Governor Allocations: Monitor daily 24-hour API limit usage and streaming event limits using the Salesforce Limits API.
Summary
Mastering Salesforce integration patterns ensures your system remains scalable, secure, and responsive. Align your architecture with transaction timing, payload size, and data ownership to choose the right balance between point-to-point callouts, asynchronous pub/sub events, bulk data loading, and real-time data virtualization.