Technology Blogs by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
cancel
Showing results for 
Search instead for 
Did you mean: 
malteschluenzkc
Participant
MPL attachments make it easy to analyze and debug past interface executions within the message monitoring of SAP CPI. They are handy not only while developing an integration but also while analyzing the root cause of an incident in the production environment easily.
However, there are limitations to this approach as SAP has implemented a circuit breaker to block the addition of MPL attachments when 1 GB of them has been stored within 24 hours already (SAP Note: 2593825). SAP recommends to do not use the MPL attachments for that or limit the usage, instead, the log level TRACE should be used. Sadly, this is limited to a 10-minute timeframe. Therefore, it requires strict alignment with functional colleagues for testing and reproduction of incidents. Furthermore, it makes it difficult to test some higher loads (which have a longer execution time, e.g. sending a couple of thousand materials from a backend system) and analyze occurring issues.
As we have faced this issue a couple of times while developing over the last weeks, we have found the following solution which works well for us so far:

We have changed all of our MPL attachments logging scripts to the one below. This enables us to control, whether we want to create the logs or not. In consequence, we can activate the MPL attachment logging for a specific time frame to enable effective reproduction of incidents with functional colleagues over a longer timeframe as well as to deactivate logging when we test heavier loads.
import com.sap.gateway.ip.core.customdev.util.Message;
import groovy.xml.*;
import java.util.regex.*;
import java.util.HashMap;

def Message processData(Message message) {
def body = message.getBody(java.lang.String) as String;

// Get LogLevel of the artifact
def map = message.getProperties();
def logConfig = map.get("SAP_MessageProcessingLogConfiguration");
def logLevel = (String) logConfig.logLevel;

def messageLog = messageLogFactory.getMessageLog(message);
if(messageLog != null){
// Only log when LogLevel of iFlow == Debug || Trace
if(logLevel.equals("DEBUG") || logLevel.equals("TRACE")) {
def bodyNice = XmlUtil.serialize(body); // Make XML fancy
messageLog.setStringProperty("Logging#3", "Printing Payload As Attachment");
messageLog.addAttachmentAsString("3. Outgoing", bodyNice , "text/plain");
} // Here it would be possible to add logging alternatives in case of other log levels
}

return message;
}

Now the question came up on how to check which record has failed during execution. Luckily, there is a feature to set a custom id that is displayed within message monitoring called Application ID. Herefore you only need to set SAP_ApplicationID as a message header (e.g. with a content modifier) and then it is getting displayed (below is an example, more information: Specifying Application ID, SAP_Sender and SAP_Receiver Fields. In this way, a functional id that identifies the record(s) can be stored and provided to the colleagues to recreate the issue while the MPL attachment logging is activated.


I hope that this might help you, that you enjoyed reading and appreciate your feedback, thoughts, and comments.
14 Comments
Labels in this area