ARTICLE AD BOX
We have a Spring Boot application deployed on AWS Lambda that makes outbound calls to OCPI partner APIs (EMSP roaming partners). We use @Async for these outbound calls to avoid blocking the main handler thread. The problem is these async calls never complete on Lambda, whereas the equivalent Node.js Lambda (also making fire-and-forget HTTP calls) works fine. Java code that fails silently:
@Async public void notifyPartner(String partnerId, Session session) { // This never executes on Lambda restTemplate.postForEntity(partnerUrl, session, Void.class); }Node.js equivalent that works:
exports.handler = async (event) => { fetch('https://partner.api/session', { method: 'POST', body: JSON.stringify(event) }); return { statusCode: 200 }; // fire-and-forget, but works };Questions:
1. Why does Lambda freeze Java background threads but not Node.js async calls?
2. Is this a Java/Spring Boot issue, or a Lambda execution model issue?
3. What is the correct pattern for making reliable outbound HTTP calls from a Java Spring Boot Lambda without blocking the handler response?
What I've tried: - Using CompletableFuture.runAsync() — same problem - Using Spring WebClient (reactive) — same problem unless .block() is called - The same code works perfectly on EC2 with a long-running container
