Skip to main content

Posts

Parsing Complex CSVs and JSON in Salesforce using DataWeave in Apex

  Processing multi-megabyte CSV files or deeply nested JSON architectures directly within Salesforce has historically been a perilous task. Developers frequently encounter   System.LimitException: Too many heap size   or   System.LimitException: Apex CPU time limit exceeded   when attempting to parse and transform this data. Traditional approaches relying on standard string manipulation or regex fail to scale gracefully. By leveraging DataWeave in Apex, data engineers and Salesforce developers can offload complex payload transformations to a purpose-built engine, drastically reducing CPU time and memory consumption. The Core Problem: Heap Limits and Immutable Strings To understand why it is so difficult to parse CSV Salesforce Apex implementations natively, we must look at how the JVM-backed Apex runtime manages memory. Strings in Apex are immutable. When you attempt to parse a CSV using  String.split('\n') , the runtime does not simply place pointers acros...

Handling Salesforce Platform Events Limits and EventBus.RetryableException

  Designing an enterprise Salesforce integration around a Salesforce event-driven architecture often works flawlessly in sandbox environments. However, once production loads scale, architectural cracks begin to show. You experience silent data drops, unhandled external API timeouts, and the dreaded   LIMIT_EXCEEDED   errors when hitting hourly publishing limits. When building resilient external integrations, treating Platform Events simply as asynchronous triggers is insufficient. You must explicitly manage batch processing, transient failures, and strict platform limits. This guide details the technical root causes behind dropped messages and exhausted limits, providing a production-ready architectural pattern leveraging  EventBus.RetryableException  and Dead Letter Queues (DLQ). Understanding the Failure Mechanisms To prevent dropped events and limit breaches, you must understand how Salesforce processes High-Volume Platform Events under the hood. 1. The Hourl...