on 09-21-2022 1:39 PM
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.
Thanks
Sandeep
Have you tried: cds.spawn?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
+1 for cds.spawn, please see example https://youtu.be/WTOOse-Flj8?t=1688
Thanks I tried to do cds.spawn in "after" hook method but unfortunately , my staging table is not having the data which is inserted in "on" hook method of the action .
If I do explicit commit using cds.tx in on even at the time of inserting data into staging table. I got below mentioned error
HANA commit Error
Sandeep
An alternative to Gregors answer is using Messaging, you can start out with In-Process Messaging and later switch to SAP Event Mesh if required.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
95 | |
11 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.