Skip to Content
Product Information

Trigger Email notifications from Cloud Platform Integration

Introduction:

In most of the integration implementation projects, the major challenge faced by integration consultants is to continuously monitor the data flow between cloud & on-premise systems and provide a live tracking of the failed messages so that the business is not impacted due to failed replications. This blog post will help the integration consultants to trigger dynamic e-mail alerts to a predefined e-mail address when an interface call fails in Cloud Platform Integration.

 

Main Part: Cloud Platform Integration Customization to trigger e-mail notification

Step1:
Custom Iflow for email server connection
Cloud Platform Integration will  connect the smtp mail server. So iflow is required to connect the SMTP mail  to customer server, which will send the notifications

Step 2:
Process Direct connection helps us to call this iflow inside another iflow using the end point maintained in the connection property.

 

Step 3:
A Groovy script is needed to process the message parameter as per the customer specific content.

/*
 The integration developer needs to create the method processData 
 This method takes Message object of package com.sap.gateway.ip.core.customdev.util 
which includes helper methods useful for the content developer:
The methods available are:
    public java.lang.Object getBody()
	public void setBody(java.lang.Object exchangeBody)
    public java.util.Map<java.lang.String,java.lang.Object> getHeaders()
    public void setHeaders(java.util.Map<java.lang.String,java.lang.Object> exchangeHeaders)
    public void setHeader(java.lang.String name, java.lang.Object value)
    public java.util.Map<java.lang.String,java.lang.Object> getProperties()
    public void setProperties(java.util.Map<java.lang.String,java.lang.Object> exchangeProperties) 
       public void setProperty(java.lang.String name, java.lang.Object value)
 */
import com.sap.gateway.ip.core.customdev.util.Message;
import java.util.HashMap;

def Message processData(Message message) {
    //Body 
       def body = message.getBody();
       
def map = message.getHeaders();
//Get initialized cached entity form Header
  String sExceptionMessage = map.get("ExceptionMessage");
  String sExceptionTrace = map.get("ExceptionTrace");
  String sParentMPLId = map.get("ParentMPLId");
  String siFlowName = map.get("iFlowName");
  
  String CPITenantURL; // = System.getenv("HC_APPLICATION_URL");
  String UrlPart1 = System.getenv("HC_APPLICATION");
  String UrlPart2 = System.getenv("HC_HOST");      
  String UrlPart3 = '{"messageGuid":"';    
  String UrlPart4 = '"}';
  
       UrlPart1 = UrlPart1.replaceAll("iflmap","");
       if(UrlPart1 != null || UrlPart2 != null || UrlPart3 != null || sParentMPLId != null ||  UrlPart4 != null){
         CPITenantURL = "https://" + UrlPart1 + "-tmn.hci." + UrlPart2 + "/itspaces/shell/monitoring/MessageDetails/" + UrlPart3 + sParentMPLId + UrlPart4;
       }
       https://<hostname:port>/itspaces/shell/monitoring/MessageDetails/{"messageGuid":"<mplGUID>"} 
       if(CPITenantURL != null){
         message.setProperty("EPTenantURL", CPITenantURL);
       }
       if(sExceptionMessage != null){
         message.setProperty("EPExceptionMessage", sExceptionMessage);
       }
       if(sExceptionTrace != null){
         message.setProperty("EPExceptionTrace", sExceptionTrace);
       }
       if(sParentMPLId != null){
         message.setProperty("EPParentMPLId", sParentMPLId);
       }
       if(siFlowName != null){
         message.setProperty("EPiFlowName", siFlowName);
       }
       return message;
}

 

Step 4:
SMPT connection to call the customer mail server: Set up the SMTP connection to the mail exchange server

Sample e-mail body content:

Dear  IT Admins,

An internal error occurred in iflow ${property.EPiFlowName}. For error details check MPL ID ${property.EPParentMPLId} in message monitoring or use the URL ${property.EPTenantURL}

Time: ${date:now:yyyy-MM-dd hh:mm:ss a}

Find below exception details for quick reference.
${property.EPExceptionMessage}

Regards,
Cloud Platform Service

 

Step 5:
Calling the custom IFlow in business flow
-> Use an exception subprocess to call the email notification iflow when the exception is called.
-> In the connection in subprocess provide the URL defined in the custom iflow creation.

When ever an error is logged in Cloud Platform Integration an email is triggered to the defined mail ids.
Sample email as below

 

Conclusion:
With this blog post, we learnt how to identify Cloud Platform Integration message parameters, build the mail body content using message parameter and finally push this as e-mail to IT Administrators for further tracking of messages.

2 Comments
You must be Logged on to comment or reply to a post.