Hello,
Currently, I'm creating iFlows with custom interfaces. When one puts an exception subprocess in an iFlow with an error/escalation end the sender will receive a message like below:
An internal server error occured: Message ended with Escalation end event. The MPL ID for the failed message is : <MPL ID> For more details please check tail log.
What I would like to do is to return a custom message, while maintaining the escalated / error label in the message monitor.
My question is whether this is possible to do and how.
Thanks in advance!
Bram
Request clarification before answering.
Hello Bram,
I have tried this feature and its not working as expected. Below are the few pointers.
1) Custom Exception can be set but Message Processing Status in CPI would be COMPLETED ( Usage of Error End or Message End ).
----> Remove property "CamelExceptionCaught" using Content Modifier and use below script.
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();
map.put("Content-Type", "application/json");
map.put("CamelHttpResponseCode", 400);
message.setBody("{\"status\": \"Hey Bond,please check CPI monitoring for error details\"}");
return message;
}
2) You want to make Message Processing Status in CPI to be FAILED or ESCALATED with standard error response
---->Just add the Exception Subprocess and set the event as Error End or Escalation.
3) You want to throw Custom Exception back to Sender and set the Message Processing Status in CPI to be FAILED or ESCALATED.
---->This is not working in SAP CPI and following up with development team.You can raise Ticket to SAP team so that this can be prioritized.
Regards,
Sriprasad Shivaram Bhat
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
bramkeijers and sriprasadshivaramabhat
do we have any update regarding Option 3
3) You want to throw Custom Exception back to Sender and set the Message Processing Status in CPI to be FAILED or ESCALATED.
---->This is not working in SAP CPI and following up with development team.You can raise Ticket to SAP team so that this can be prioritized.
Hi Team,
I'm looking for the same requirement. Any latest update on this please.
Thanks,
Santosh
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Bram,
Please access the documentation:https://help.sap.com/docs/integration-suite/sap-integration-suite/use-custom-header-properties-to-search-for-message-processing-logs
You can set custom property or header in content modifier and search for custom status in the monitor. Although the flow is completed ,you will check the flow's custom status "FAILED" or "ERROR"(set by yourself).

Regards,
Henry
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Bram
Use a Groovy script in your exception subprocess (with error end event) to throw a new exception (any type you like). The script could be as simple as below which adds a prefix to the exception that triggered the subprocess.
def Message processData(Message message) {
throw new Exception('This is my new custom exception:-' + message.getProperty('CamelExceptionCaught'))
return message
}
This new exception will be returned to the caller, as well as logged into the failed message.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Eng Swee,
When I use this script in an exception subprocess and the integration flow with error/escalation end, but in each case the autput is as follows:
HTTP code 500
An internal server error occured: java.lang.Exception: -This is my new custom exception-@ line 4 in script.groovy. The MPL ID for the failed message is : <mpl ID> For more details please check tail log.
I'm looking for a solution that only outputs -This is my new custom exception- . In that way there is freedom in the format and the content of the message.
Do you have any ideas how to achieve this? For instance, can we override Exception objects? I'm a bit cautious to do these kind of operations, I once resetted the time of an instantiation of an integration flow by altering timestamp objects 😉
Thanks for helping out!
Bram
I'm not aware of a way to fully replace the whole format of the exception that is returned to the sender. I think somewhere within the CPI framework, the exceptions are wrapped with this "An internal server ...." message and yes, probably not a good idea to go about messing with that.
IMHO, it should be good enough for you to replace the error content using the above approach and as long as you provide enough reason for the error, it should be sufficient for the sender to figure out what went wrong.
Hello Eng,
It works with soap sender, probably because it has a fault response but not http. with HTTP, it behaves as original question posted here. if you use end message, then it is completed but sender gets the correct response, if you throw exception inside exception sub-process, sender get the usual internal service with MPL ID error. Is there way to send customized response to sender while making message failed in CPI?
One thing to add, it shows the correct response in CPI logs but not in postman which is acting as sender here.
Error in CPI:
com.sap.it.rt.adapter.http.api.exception.HttpResponseException: An internal server error occured: java.lang.Exception: org.apache.cxf.interceptor.Fault: Could not send Message.@ line 4 in script1.groovy.
The MPL ID for the failed message is : AGLWcIjq97sgNVA4bi2VpdPx-FMnError in postman:
An internal server error occured: The MPL ID for the failed message is : AGLWfB0nhabyY_Pd0uB6bek6M5I3
Thanks,
Hemant
Hello Bram,
Could you please let me know the sender adapter you are using in your IFlow.
Regards,
Sriprasad Shivaram Bhat
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Bram,
Please check the following blog site:
https://blogs.sap.com/2015/01/12/blog-4-modelling-exceptions-in-integration-flows-hci-pi/
Regards,
Balázs
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Balazs,
The blog describes my current implementation: exception subprocess with error start, message end and a content modifier setting a custom message. This works, but the exception is labelled as "completed" in the message monitor. I would like to have the exceptions labelled as "failed" or "escalated", which is only possible with an error/escalation end but then the message gets overwritten.
I've learned that setting the header "CamelHttpResponseCode" controls the HTTP response code to the sender, perhaps there is a header or parameter as well for the labeling of messages in the message monitor?
Thanks in advance!
Bram
Hi,
Have you tried adding a Content Modifier in the Exception sub process and define the body with your custom message.
Regards,
Srinivas
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
| User | Count |
|---|---|
| 10 | |
| 5 | |
| 5 | |
| 5 | |
| 3 | |
| 3 | |
| 2 | |
| 1 | |
| 1 | |
| 1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.