Skip to Content
6 days ago

Async /Non Blocking Mode - SAP CAP

222 Views Last edit 6 days ago 2 rev

Hello Everyone,

Kindly let me know the best way to handle task in background/non-blocking format which actually get triggers on the HTTP POST request instead of a scheduled job.

I have created a action named as publishNotification in SAP CAP.

Here are the details of the logic

In ‘On’ Event handler of an action , I am inserting entries in staging table.

And in ‘After’ Event I am calling async function named as triggerNotification which is wrapped in method setTimeout .I wrapped so that HTTO POST request ( for a action -- publishNotification ) is not blocked and implicit database commit happens . In this way I will have data in staging table

The logic of triggerNotification is to loop on staging table and triggers EMAIL and SMS and update the staging table with sent status.

I found that when no of recipient is more than 100, program failed to trigger EMAIL and SMS . It happens randomly . Even when I trigger multiple HTTP request simultaneously using multiple browser session , notification didn’t triggered for few users.

Kindly let me know , if there any better approach in SAP CAP to handle such situation.