cancel
Showing results for 
Search instead for 
Did you mean: 

variables shared among multiple processes of same application in SAP Cloud Platform

Former Member
0 Kudos

Hi All,

Currently i have implemented a java servlet deployed on SAP Cloud platform Neo environment, which calls the SAP Mobile Services to send Emails on a periodic basis.

The problem I am facing right now is that, if I have multiple processes of the application running, I receive multiple duplicate emails for the same application. Ex. If i configure 3 processes in my application, I get 3 duplicate emails, where I expect only one email.

Can you let me know if there is any way to control this, so that i get only one email, no matter how many processes of the application are running ?

I cannot create one more application just to send emails as this would be hard to maintain.

I am looking for any variable which will be shared among all the processes, so that i can write a logic in my application to not send email if another process has sent it using this shared variable.

Regards,

Suhas R

Accepted Solutions (0)

Answers (1)

Answers (1)

Ivan-Mirisola
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi Suhas,

AFAIK the SDK doesn't give you a method to obtain the process ID - which could be used to determine which one is responsible for sending the emails out.

However, you could call the monitoring API just after the first application instance has started.

https://api.hana.ondemand.com/monitoring/v1/accounts/<subaccount_technical_name>/apps/<application_n...

This API wil give you the process ID under 'processes[0].process' - which would be the first instance of the process. The id value is the application unique identifier. You can than store in a transient variable that this is the first execution and this instance should be the one responsible for sending mails. Whenever you start a new instance of your application, the same code will be executed after it has started. The code should check if the list of processes has increased. If so, you do not store anything in the transient variable, meaning any new processes that came up will not contain the transient variable set to true. With that in mind, you could end up with several instances of the same application, but only the first one will have the transient variable set to true.

Whenever you run the code to send mails, all you need to do is check this transient variable before running it.

Best regards,
Ivan