HCI – Payload Logging using Groovy Scripts – Part 2 – Use Externalized Parameters
As discussed in my previous blog, HCI – Payload Logging using Groovy Scripts logging of payloads should be used prudently. Typically you would like the logging to be disabled and have options to enable this only on a need basis.
If you are from a PI background, you would be well aware of parameters like TRACE_LEVEL, LOGGING_SYNC and Integrated Configuration Logging Options that enable you to turn on / off logging & staging when required. So how can this be done in HCI using the Groovy scripts we described in the previous blogs?
Externalized Parameters in HCI
Some background first – HCI enables you to define parameters that can be controlled externally in your Integration Flow. Typical examples of these are SOAP/HTTP URLs, FTP Server Host,etc which will typically vary in each environment. There is already content on Externalized Parameters for HCI on SCN and would recommend you read that or the corresponding documentation from SAP – Externalizing Parameters of Integration Flow
To be able to define Logging Dynamically we will be using a custom Externalized Parameters, so you can enable and disable logging without having to make changes to your Integration Flow or the Groovy script.
Integration Flow Changes
We will continue to use the sample Integration Flow described in my previous blog with an additional Content Modifier Step and some changes in the Groovy script as described below.
|Groovy Script Change||
Setting of Externalized Parameters
Once the Content Modifier step is defined, the Externalized Parameters tab should contain the Parameter with the name as defined in our Content Modifier step. In this case: externalParamLogger. Set the default value of the Parameter as 0 (Zero). Save and Deploy your Integration Flow.
Test your flow with External Parameter Value set to 0
Trigger your Integration flow with the External Parameter Value set a 0. The Integration Flow executes and the Groovy Script does not log the payload as the value is set to 0. As seen in the image below no attachment is available.
Test your flow with External Parameter Value set to 1
To update your external parameters, navigate to Window –> Show View –> Other. In your Show View dialog box, navigate to Other –> Configurations
In the Configurations Pane that opens, navigate to your project and double click on the same. In my case the name of my project is – Prj_PayloadAsAttachment
Go to Externalized Parameters tab and update the value of externalParamLogger as 1 and click on Save Parameters
Right Click on your project in Configurations –> Deploy Integration Content. Your Integration Flow is now updated to have the Logging Enabled!
Re-trigger the Interface and you should see the logs with the attachment as the Logger is now set to Value 1.
As seen in this blog, Externalized Parameters provide you with options to provide parameters to your Integration flow dynamically. This along with some smart Groovy Scripting enables you to dynamically control payload logging.
Good blog bhavesh,
One doubt, as explained how to use the externalized parameters in SOAP for trigger or in SFTP. (Via the SOAP UI )
Thanks in advance,
This help link is a good starting point on how to Externalize Parameters for the adapter's in question. Externalizing Parameters
We are not able to create an external parameter for the Content modifier exchange property as it is greyed out:
We can set this up in Eclipse:
When we deploy, the deployment is successful - but the content modifier still does not show this property. Seems like a issue with SAP HCI. Is there a work around to do this? It seemed like this feature was not supported in the Web UI so it was recommended to create the external parameter through Eclipse but it's not working.
Thanks for your help in advance.
I did the same steps as per your BLOG:
Deployment shows successful - but when I open this up in Web UI - it still has the old constant that I had defined in the Web UI. So somehow the issue is with the deployment it seems.
Any ideas why this is not working?
Hi Jay ,
We too had the same issue. we tried the below steps and it worked.
The best way that I found was to import the flow into Eclipse and make the changes there. Then you have to export the flow as an archive zip file. You have to replace the flow in the WebUI. I don't know why it is taking SAP so long to add this functionality to the WebUI. But it is taking way too long to have this simple functionality implemented.
I think your wish is fulfilled now.
Thakns Manoj - That's great news! So now we don't have to keep on switching between the HCI web development interface and Eclipse.
I still have the "External parameter" option grayed out:
Were you able to define this kind of parameter thru CPI web interface?
As per Payload Logging, I am storing data as request and response payloads in Message Monitoring logs. How i will delete the payload Logging logs. Please suggest me the way how to delete.
This is a very nice blog .But at that time the web ui had limitations that it could not handle external parameter at content modifier.But latest version of Content modifer has solution to it.
Please follow below link: