Global Custom Exception Handling in SAP CPI: CPI integrations fail for many reasons - API timeouts, invalid data, authentication errors. Without proper handling: Errors go unnoticed, Recovery becomes manual, Support teams get flooded. A global exception strategy ensures: Consistent error handling across all iFlows Automatic retries & notifications Clean error logging for troubleshooting 3-Tier Exception Handling Framework 1. Local Try-Catch (Message Mapping Level) groovy: try { // Your mapping logic } catch(Exception ex) { def errorMsg = "Mapping failed: ${ex.message}" throw new IllegalStateException(errorMsg) //Bubbles up to iFlow } Field-level validation errors 2. iFlow-Level Exception Subprocess xml <Exception SubProcess> <Default Exception Handler> <Retry>3</Retry> <!-- Auto-retry 3 times --> <Wait>5 seconds</Wait> <On Failure> <!-- Final fallback --> <Data Store Write> <!-- Log error --> <Send Alert to Slack/Email> </On Failure> </Default Exception Handler> <!-- Custom exception routes --> <Route Message when="contains(${header.SAP_ErrorCode},'AUTH_FAIL')"> <Notify Security Team> </Route> </Exception SubProcess> 3. Global Exception Handler (Reusable) groovy // Shared Groovy Script "GlobalErrorHandler" def handleError(Message message, String context) { def errorDetails = [ timestamp: new Date(), iFlow: "${property.SAP_ProcessDefinition}", error: "${property.CamelExceptionCaught}", payload: message.getBody(String.class).take(1000) // Truncated ] // Write to Data Store def ds = message.getExchange().getProperty('DataStoreWriter') ds.storeData("Error_${UUID.randomUUID()}", errorDetails) // Custom logic based on error type if (context == "RETRYABLE") { message.setHeader("SAP_RetryCount", 1) } else { message.setHeader("SAP_NotifyTeam", "Support") } } Implementation Step 1: Create Reusable Components Global Error Handler Script (Groovy) Deploy Handles logging, notifications, retry logic Error Data Store Configure a dedicated Data Store named Exception Template iFlow Cloneable flow with pre-built exception subprocess Step 2: Standardize Error Payloads json { "error_id": "{{$guid}}", "timestamp": "{{$timestamp}}", "iFlow": "OrderToCash_Prod", "severity": "HIGH", "root_cause": "SFAPI_429_TOO_MANY_REQUESTS", "recommended_action": "Wait 5 mins then retry" } Step 3: Connect Monitoring Tools SAP Alert Notification → Email/SMS Splunk/Dynatrace Integration → Central logging Slack Webhook → Real-time alerts Advanced Patterns 1. Circuit Breaker Pattern groovy if (property.SAP_FailureCount > 5) { // Stop processing for 1 hour setProperty("SAP_CircuitBreaker", "OPEN") addTimer("RESET_CIRCUIT", 3600) } 2. Dead Letter Channel xml <On Exception> <JMS Producer Queue="CPI_DLQ"> <ErrorDetails>${property.CamelExceptionCaught}</ErrorDetails> </JMS> </On Exception>
Auto retry logic for failed emails
Explore top LinkedIn content from expert professionals.
Summary
Auto-retry logic for failed emails is a system design approach that automatically attempts to resend emails when delivery fails, helping to resolve temporary issues without manual intervention. This tactic improves reliability by distinguishing between errors that can be fixed through retries and those that require other actions or notifications.
- Set retry limits: Decide in advance how many times your system should automatically attempt to resend a failed email so you avoid unnecessary delays and system overloads.
- Time retry attempts: Space out retry attempts using techniques like exponential backoff to give the system time to recover and prevent all retries from happening at once.
- Trigger smart alerts: Notify support teams or recipients only after retries have truly failed, and customize notifications based on the type of error and the user’s preferences.
-
-
At $15M ARR, 8% churn = $100k/month gone. If I were running growth at a consumer SaaS, this is the recovery system I’d use to claw it back: Step 1: Let retries lead, emails follow Don’t treat emails and retries as separate tracks. - Retry multiple times first (smart logic based on decline reason) - Only send emails after a retry fails - Recovery attempts should dictate email timing (not a dumb fixed schedule) This preserves trust and maximizes silent recovery. __ Step 2: Email sequence (triggered by failed retries) Email 1 (sent after first retry fails) - Subject: “We can’t process your payment” - Clear, concise, personalized (name, amount, last 4 of card) - Direct link to branded, mobile card update page (remove friction) Follow-ups: - Sent after subsequent retries fail - Spaced based on retry logic - Escalate urgency slightly each time - 3–4 total attempts, then stop. Respect the inbox. __ Step 3: Maximize impact - Use different sender addresses (same domain) - Keep subject lines clear and direct - Localize send times to user’s timezone - Short, mobile-first formatting - Monitor replies, they’re gold for fixing churn friction Pro tip: The sender name matters more than you think. “Acme Billing Team” builds trust. “NoReply@” kills it. __ TAKEAWAY This isn’t just email automation. It’s adaptive, intelligent recovery that earns you revenue and goodwill. What’s the smartest thing you’ve done to reduce churn that nobody talks about?
-
Retry Pattern is Good for Resilience, But Only if You Do It Right. Here are 4 things to remember when using the Retry Pattern. The Retry Pattern is a design approach. It enhances reliability and resilience by automatically reattempting a failed operation or request. 𝟏. 𝐒𝐞𝐭 𝐚 𝐑𝐞𝐚𝐬𝐨𝐧𝐚𝐛𝐥𝐞 𝐑𝐞𝐭𝐫𝐲 𝐋𝐢𝐦𝐢𝐭: Determining the right number of retries is critical. Too few retries might prevent the resolution of temporary issues, while too many retries could lead to excessive load or long delays in recognizing a persistent problem. I never go over 3 retries. 𝟐. 𝐈𝐦𝐩𝐥𝐞𝐦𝐞𝐧𝐭 𝐄𝐱𝐩𝐨𝐧𝐞𝐧𝐭𝐢𝐚𝐥 𝐁𝐚𝐜𝐤𝐨𝐟𝐟: Instead of retrying immediately, implement an exponential backoff strategy. This means that after each failed attempt, you increase the time before the next retry, not overwhelming the system and giving it time to recover. Exponential backoff helps avoid a stampeding herd effect, in which all failed requests suddenly hit the system simultaneously after a short time. 𝟯. 𝗜𝗱𝗲𝗻𝘁𝗶𝗳𝘆 𝗥𝗲𝘁𝗿𝗶𝗮𝗯𝗹𝗲 𝗘𝗿𝗿𝗼𝗿𝘀: Not all errors are worth retrying. Focus on retrying only transient errors: • 408 Request Timeout • 5XX (Server did something bad) Avoid responses like: • 400 (Bad Request) • 403 (Forbidden) They are not recoverable, so the retry logic shouldn't retry them. 𝟰. 𝗖𝗼𝗺𝗯𝗶𝗻𝗲 𝘄𝗶𝘁𝗵 𝗖𝗶𝗿𝗰𝘂𝗶𝘁 𝗕𝗿𝗲𝗮𝗸𝗲𝗿: The Retry Pattern works well when combined with a circuit breaker mechanism. A circuit breaker monitors a service's health and prevents repeated calls to a failing service. If a certain threshold of failures is reached, the circuit breaker opens, temporarily preventing further requests. This gives the service time to recover before attempting retries again. When done correctly, the Retry Pattern minimizes disruptions and optimizes system performance!