real-time-vs-batch-integration
When to use this skill: choosing between real-time (synchronous callouts, Platform Events, CDC, Pub/Sub API) and batch (Bulk API 2.0, scheduled ETL) integration patterns. Trigger keywords: should I use real-time or batch, how to sync high-volume data, when to use Platform Events vs Bulk API, integration latency vs volume tradeoff. NOT for Batch Apex internals (use batch-apex-patterns), NOT for MuleSoft middleware design (use middleware-integration-patterns), NOT for CDC field tracking configuration.
Best use case
real-time-vs-batch-integration is best used when you need a repeatable AI agent workflow instead of a one-off prompt.
When to use this skill: choosing between real-time (synchronous callouts, Platform Events, CDC, Pub/Sub API) and batch (Bulk API 2.0, scheduled ETL) integration patterns. Trigger keywords: should I use real-time or batch, how to sync high-volume data, when to use Platform Events vs Bulk API, integration latency vs volume tradeoff. NOT for Batch Apex internals (use batch-apex-patterns), NOT for MuleSoft middleware design (use middleware-integration-patterns), NOT for CDC field tracking configuration.
Teams using real-time-vs-batch-integration should expect a more consistent output, faster repeated execution, less prompt rewriting.
When to use this skill
- You want a reusable workflow that can be run more than once with consistent structure.
When not to use this skill
- You only need a quick one-off answer and do not need a reusable workflow.
- You cannot install or maintain the underlying files, dependencies, or repository context.
Installation
Claude Code / Cursor / Codex
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/real-time-vs-batch-integration/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How real-time-vs-batch-integration Compares
| Feature / Agent | real-time-vs-batch-integration | Standard Approach |
|---|---|---|
| Platform Support | Not specified | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | Unknown | N/A |
Frequently Asked Questions
What does this skill do?
When to use this skill: choosing between real-time (synchronous callouts, Platform Events, CDC, Pub/Sub API) and batch (Bulk API 2.0, scheduled ETL) integration patterns. Trigger keywords: should I use real-time or batch, how to sync high-volume data, when to use Platform Events vs Bulk API, integration latency vs volume tradeoff. NOT for Batch Apex internals (use batch-apex-patterns), NOT for MuleSoft middleware design (use middleware-integration-patterns), NOT for CDC field tracking configuration.
Where can I find the source code?
You can find the source code on GitHub using the link provided at the top of the page.
SKILL.md Source
# Real-Time vs Batch Integration This skill activates when a practitioner must choose between real-time and batch integration approaches in Salesforce. It provides a decision framework grounded in the Salesforce Integration Patterns guide, covering synchronous callouts, Platform Events, Change Data Capture, Pub/Sub API, and Bulk API 2.0, and produces a defensible pattern recommendation with limits and tradeoffs. --- ## Before Starting Gather this context before working on anything in this domain: | Context | What to gather | |---|---| | Volume | Records changing per hour at peak. Above ~2,000 records per transaction window is outside Apex callout capacity and requires an async or bulk mechanism. | | Latency tolerance | Sub-second acknowledgement, near-real-time (seconds to minutes), or nightly window acceptable? | | Transactionality requirement | Synchronous callouts participate in the Salesforce DML transaction and can be rolled back; CDC events and Platform Events are fire-and-forget once published. | | Most common wrong assumption | Treating Platform Events and synchronous Apex callouts as equivalent "real-time" options — callouts are synchronous (120s timeout, 100/tx limit); Platform Events are async with up to 72-hour replay but no rollback guarantee. | --- ## Core Concepts ### Synchronous Callout (Remote Process Invocation — Request and Reply) An Apex HTTP or SOAP callout fires inline within a DML transaction. The calling transaction blocks until the external system responds or the 120-second timeout elapses. Governor limits: 100 callouts per transaction, 120-second timeout per callout, and callouts cannot be made from triggers that already have DML pending (the "callout after DML" restriction). This pattern is correct when: volume is low (single record or small sets), the caller needs an immediate response to make a commit/rollback decision, and the external system can respond within the timeout. ### Asynchronous Event-Driven (Platform Events and CDC/Pub/Sub API) Platform Events are schema-defined Salesforce objects published via `EventBus.publish()` or DML insert. Subscribers receive events asynchronously via Apex triggers, CometD streaming, or Pub/Sub API gRPC. Key behavioral facts: - Events are durable in the event bus for up to **72 hours** (standard volume) or **3 days** (high-volume); subscribers can replay from any point in that window using a replay ID. - Publishing succeeds even if no subscriber is listening — the event is not lost. - Events are **not rolled back** when the publishing transaction rolls back (as of Spring '25, standard Platform Events do fire even on transaction rollback by default unless the `publishBehavior` is set to `PHASE_AFTER_COMMIT`). - CDC events (Change Data Capture) are automatically generated by the platform for tracked objects; they carry field-level change data and the replay window is 3 days. - Pub/Sub API provides a gRPC-based subscriber interface suitable for high-throughput external consumers. ### Bulk API 2.0 (Batch Data Load) Bulk API 2.0 is the correct mechanism for loading or extracting large volumes of records — Salesforce recommends it for datasets above 2,000 records. Jobs are asynchronous and processed in the background. Key behavioral facts: - No cross-batch atomicity: a job that processes 500,000 records in multiple batches will commit successful batches even if later batches fail. There is no "all-or-nothing" job-level rollback. - Bulk API 2.0 jobs must be processed outside peak business hours when possible to avoid resource contention; Salesforce guidance recommends scheduling large loads during off-peak windows. - The API uses CSV ingest format; each job has a hard limit of 150 million records per rolling 24-hour period. - PK chunking (available in legacy Bulk API, not natively in Bulk API 2.0 jobs) is required for very large queries; use query jobs or SOQL with cursor-based pagination instead. ### Hybrid Approach Many production integrations combine patterns: a Platform Event or CDC subscriber receives a change notification in near-real-time but delegates heavy record processing to a queued Bulk API job or a scheduled batch. This decouples the event detection latency from the volume constraint. --- ## Common Patterns ### Pattern 1: Trigger-Based Sync for Low-Volume Transactional Records **When to use:** Individual record creates/updates that require immediate confirmation from an external system (e.g., creating a payment authorization, validating an address, checking inventory for a single order line). **How it works:** 1. An Apex trigger or process fires on record insert/update. 2. A `@future(callout=true)` method or a queueable with callout support issues an HTTP request to the external endpoint. 3. The response updates a status field on the Salesforce record in a follow-on DML. 4. Retry logic is handled by re-queuing or using a Platform Event to signal failure. **Why not Platform Events here:** The caller needs a synchronous confirmation to decide whether to commit or surface an error to the user. Platform Events do not provide a reply. **Limits to enforce:** Verify fewer than 100 callouts will fire per transaction. Use `@future` or Queueable to avoid the "callout after DML" error. Set a Named Credential — never hardcode endpoint URLs or credentials. ### Pattern 2: Event-Driven Near-Real-Time Sync via Platform Events **When to use:** Volume is moderate (hundreds to low thousands of events per hour), latency must be under a few minutes, and the business does not require transactional rollback on the receiving side (e.g., broadcasting order status changes to a fulfillment system). **How it works:** 1. A trigger or Flow publishes a Platform Event on record change. 2. An external subscriber (MuleSoft, custom app, AWS Lambda) listens on CometD or Pub/Sub API gRPC. 3. The subscriber processes and writes to the target system. 4. Replay IDs allow the subscriber to recover from downtime without data loss within the 72-hour window. **Why not synchronous callouts:** External system downtime or latency spikes would block the Salesforce transaction and risk timeout errors at scale. ### Pattern 3: Bulk API 2.0 Scheduled Batch Sync **When to use:** Volume exceeds 2,000 records per sync cycle, latency tolerance is hours (e.g., nightly ERP sync, daily customer master reconciliation), and eventual consistency is acceptable. **How it works:** 1. External ETL tool or scheduled job queries Salesforce (SOQL query job via Bulk API 2.0) or receives a data extract. 2. Target system data is transformed and staged. 3. A Bulk API 2.0 ingest job upserts records using an external ID field. 4. Job status is polled; failed records are captured in the results CSV and re-queued for the next cycle. 5. Schedule jobs during off-peak hours to avoid resource contention with interactive users. **Why not Platform Events for this volume:** At sustained thousands-per-second rates, Platform Events have throughput limits (standard: 250,000 events/day for most editions) and the event bus is not a reliable high-volume ETL channel. --- ## Decision Guidance | Situation | Recommended Approach | Reason | |---|---|---| | <100 records, immediate response needed, user-facing | Synchronous callout (Apex HTTP/SOAP) | Caller needs reply to commit or surface error; volume is within callout limits | | Hundreds to low-thousands of events/hour, latency < 5 min, no rollback needed | Platform Events + external subscriber | Async, durable 72-hr replay, decouples systems | | External system needs to react to Salesforce record changes automatically | Change Data Capture + Pub/Sub API | Platform-generated, field-level diff, 3-day replay, no custom publish code | | >2,000 records per cycle, hours latency acceptable | Bulk API 2.0 scheduled job | Purpose-built for volume; callouts and Platform Events cannot handle this throughput reliably | | High event volume + need for immediate detection but deferred processing | Hybrid: CDC/Platform Event triggers a queued batch | Decouples detection latency from processing volume | | Bidirectional sync with conflict resolution | Middleware (MuleSoft) + Bulk API 2.0 or Platform Events | Salesforce-native patterns lack built-in conflict resolution; middleware handles transformation | --- ## Recommended Workflow Step-by-step instructions for an AI agent or practitioner working on this task: 1. **Establish volume and latency requirements**: ask the stakeholder for peak records-per-hour and the maximum acceptable delay from source change to destination visibility. These two axes determine the viable pattern set before any implementation begins. 2. **Confirm transactionality needs**: determine whether the integration must roll back Salesforce data if the external system rejects the payload. If yes, only a synchronous callout participates in the transaction; all async patterns are eventually consistent. 3. **Apply the decision table**: map volume + latency + transactionality to the correct Salesforce mechanism. Flag if volume exceeds callout limits (100/transaction) or Platform Event daily allocations (250,000 standard). 4. **Check governor limits for the chosen pattern**: for callouts verify the 120s timeout and 100/transaction limit; for Platform Events confirm daily event allocation; for Bulk API 2.0 confirm the 150M records/24hr limit and plan the off-peak schedule. 5. **Design the error and retry path**: synchronous callouts need try/catch + status field; Platform Event subscribers need a dead-letter queue or replay-ID restart strategy; Bulk API 2.0 jobs need results-CSV processing to re-queue failed rows. 6. **Validate with a load estimate**: calculate peak event or record rate against the chosen mechanism's limits; if headroom is under 30%, escalate to the next tier or add a hybrid buffer. 7. **Document the chosen pattern and rationale** in the integration design using the template in `templates/real-time-vs-batch-integration-template.md`, including replay window, retry approach, and failure notification path. --- ## Review Checklist Run through these before marking work in this area complete: - [ ] Volume and latency requirements are documented with numbers, not just words like "real-time" - [ ] Chosen pattern is within governor limits at projected peak load (callout limits, event allocations, Bulk API daily cap) - [ ] Transactionality decision is explicit: rollback-capable (synchronous) or eventually consistent (async) - [ ] Error handling and retry path is defined for each integration leg - [ ] Named Credentials are used for all outbound callouts (no hardcoded endpoints or credentials) - [ ] Bulk API 2.0 jobs are scheduled outside peak business hours - [ ] Platform Event or CDC replay window is sufficient for expected subscriber downtime scenarios --- ## Salesforce-Specific Gotchas Non-obvious platform behaviors that cause real production problems: 1. **Apex callout 120-second timeout is absolute** — there is no way to extend it. If the external system is slow or the payload is large, a synchronous callout will time out even at low volume. The fix is to move to a Queueable or @future callout that fires outside the user transaction, decoupling user-facing latency from external system performance. 2. **"Callout after DML" restriction** — if a trigger performs DML before the callout code runs, the callout is blocked with `System.CalloutException: You have uncommitted work pending`. This forces callouts to @future or Queueable, which means they cannot roll back the DML they follow. 3. **Platform Events do not roll back on transaction rollback by default** — as of Spring '25, `publishBehavior` defaults to `PUBLISH_IMMEDIATELY` for standard Platform Events; events already written to the bus are not retracted if the publishing transaction fails. Use `PHASE_AFTER_COMMIT` publish behavior when the event should only fire on successful commit. 4. **CDC 72-hour / 3-day replay window is a hard ceiling** — if a subscriber is down for longer than the replay window, events are gone. Design monitoring to alert if a subscriber has not polled within 48 hours so the window does not silently expire. 5. **Bulk API 2.0 has no cross-batch atomicity** — a job processing 500,000 records in multiple internal batches will commit each batch independently. If batch 3 of 10 fails, batches 1–2 are already committed and cannot be rolled back. Design idempotent upserts using external IDs so retries are safe. --- ## Output Artifacts | Artifact | Description | |---|---| | Integration pattern recommendation | Written rationale mapping volume/latency/transactionality to the chosen Salesforce mechanism | | Decision table | Populated version of the decision table in this skill with project-specific values | | Governor limit validation | Calculations showing chosen pattern is within limits at projected peak | | Error handling design | Retry approach, dead-letter strategy, and monitoring thresholds per integration leg | --- ## Related Skills - integration/middleware-integration-patterns — use alongside when MuleSoft or an iPaaS layer is involved in the integration topology - integration/api-led-connectivity-architecture — use when the integration is part of a broader API-led connectivity design - integration/error-handling-in-integrations — use for designing retry, dead-letter, and alerting patterns for whichever mechanism is chosen - apex/batch-apex-patterns — use when the batch processing logic itself is implemented in Apex Batch rather than Bulk API 2.0
Related Skills
session-management-and-timeout
Use this skill when configuring session timeout values, concurrent session limits, session IP locking, or logout behavior in Salesforce. Covers org-wide session settings, profile-level overrides, Connected App session policies, and Metadata API SecuritySettings deployment. NOT for OAuth token refresh flows, login IP ranges, or MFA/identity-provider configuration.
scim-provisioning-integration
Use when designing or reviewing SCIM-based user lifecycle provisioning into Salesforce from Okta, Azure AD / Entra, or another IdP — create/update/deactivate, group-to-permission-set mapping, attribute mapping, and deprovisioning semantics. Triggers: 'scim provisioning', 'okta scim salesforce', 'entra salesforce provisioning', 'user deactivation automation', 'group to permission set mapping'. NOT for SSO/authentication setup (see single-sign-on skills).
omnistudio-lwc-integration
Use when embedding OmniScripts in Lightning Web Components, registering custom LWC elements inside OmniScript screens, or calling OmniScript/Integration Procedures from LWC. Triggers: embed omniscript in LWC, custom LWC element in OmniScript, call OmniScript from Lightning page, omnistudio-omni-script tag, seed data JSON, OmniScript launch from LWC. NOT for standalone LWC development, standard Flow embedding, or OmniScript-to-OmniScript embedding.
integration-procedures
Use when building, reviewing, or debugging OmniStudio Integration Procedures. Triggers: 'integration procedure', 'IP', 'HTTP action', 'DataRaptor', 'rollbackOnError', 'failureResponse'. NOT for Apex-only integrations unless the main design choice is whether OmniStudio is still appropriate.
integration-procedure-cacheable-patterns
Use when designing Integration Procedures (IPs) with platform cache to cut latency and callout load. Covers cache key design, TTL selection, per-user vs org-wide partitions, invalidation on data changes, and safe fallback on cache miss/stale. Does NOT cover general IP authoring (see omnistudio-error-handling-patterns) or LWC client-side caching.
common-lwc-runtime-errors
Diagnose and fix runtime errors in Lightning Web Components including wire adapter failures, shadow DOM boundary violations, event propagation mistakes, async rendering timing bugs, NavigationMixin errors, Lightning Locker vs Lightning Web Security conflicts, and slot projection problems. Triggers: 'wire adapter returns undefined', 'querySelector returns null in LWC', 'custom event not received by parent', 'LWC component not rendering after connected callback', 'NavigationMixin page reference error'. NOT for LWC fundamentals, build/deployment errors, or Aura component debugging.
slack-salesforce-integration-setup
Use this skill when setting up or troubleshooting the Salesforce for Slack managed app — including connecting a Salesforce org to a Slack workspace, configuring the three-party admin handshake, linking Slack channels to Salesforce records, enabling record preview sharing, and managing org-level limits. Triggers on: Salesforce for Slack app not connecting, Slack org connection setup, Salesforce record sharing in Slack, Slack workspace admin approval, connecting Salesforce to Slack. NOT for building custom Slack apps or Slack bots (separate development platform), not for Slack Workflow Builder Salesforce connector (use slack-workflow-builder skill), not for Flow-based Slack messaging (use flow-for-slack skill).
sis-integration-patterns
Use this skill when designing or implementing an integration between a Student Information System (SIS) — such as Ellucian Banner, Ellucian Colleague, Anthology Student, Oracle PeopleSoft Campus Solutions, or Workday Student — and Salesforce Education Cloud. Covers the canonical Education Cloud data model objects (AcademicTermEnrollment, CourseOfferingParticipant, CourseOfferingPtcpResult, LearnerProfile, PersonAcademicCredential), external ID / upsert keying strategies using SIS-native identifiers (Banner PIDM, PeopleSoft EMPLID), batch nightly upsert patterns, Change Data Capture (CDC) for enrollment status writeback, and MuleSoft/middleware watermark patterns. Trigger keywords: SIS integration, Banner integration, PeopleSoft integration, Education Cloud data model, enrollment sync, grade writeback, AcademicTermEnrollment, LearnerProfile upsert. NOT for Salesforce Admissions Connect application processing, Financial Aid integration, Learning Management System (LMS) integrations, or general ETL tooling not involving Education Cloud objects.
salesforce-to-salesforce-integration
Use this skill to implement Salesforce-to-Salesforce integration patterns — covering the native S2S feature, API-based cross-org sync, Platform Event bridging, and Salesforce Connect Cross-Org adapter. Trigger keywords: Salesforce to Salesforce integration, cross-org data sharing, S2S feature, cross-org Platform Events, Salesforce Connect cross-org. NOT for multi-org strategy or architecture decisions (use architect/multi-org-strategy), single-org data sharing, or external (non-Salesforce) system integration.
platform-events-integration
Use when publishing Platform Events from external systems via REST API, subscribing to Platform Events from outside Salesforce via CometD or Pub/Sub API, designing replay ID strategy for durable external consumers, or handling high-volume event delivery guarantees. Trigger keywords: 'external publish platform event', 'CometD subscribe', 'Pub/Sub API', 'replay ID external', 'durable subscription', 'RetainUntilDate'. NOT for Apex-only event publishing or triggering (use platform-events-apex). NOT for Change Data Capture external subscription (use change-data-capture-integration).
middleware-integration-patterns
Use when selecting or comparing middleware / iPaaS tools (MuleSoft, Dell Boomi, Workato, Informatica) for Salesforce connectivity, or when determining whether a scenario requires middleware at all versus native Salesforce capabilities. Triggers: 'which iPaaS should I use', 'MuleSoft vs Boomi vs Workato', 'when do I need middleware for Salesforce', 'message transformation orchestration middleware'. NOT for MuleSoft Anypoint Salesforce Connector configuration (use mulesoft-salesforce-connector). NOT for API-led connectivity layer design (use api-led-connectivity). NOT for native Salesforce-to-Salesforce integration, Platform Events, or CDC.
idempotent-integration-patterns
Use when designing retry-safe integrations with Salesforce — including external ID upsert strategies, idempotency key management for inbound calls, Platform Event replay safety, and Outbound Message retry handling. NOT for Salesforce duplicate management rules.