Skip to Content

use custom message in exception subprocess with error/escalation end

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

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

5 Answers

  • Best Answer
    Nov 20, 2018 at 05:10 AM

    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

    Add comment
    10|10000 characters needed characters exceeded

  • Nov 13, 2018 at 10:01 AM

    Hi,

    Have you tried adding a Content Modifier in the Exception sub process and define the body with your custom message.

    Regards,

    Srinivas

    Add comment
    10|10000 characters needed characters exceeded

    • Hello Srinivas,

      The content modifier only changes the message in an exception subprocess when there is a message end and not an error/escalation end. Then the message seems to get overwritten.

      Any other ideas?

      Thanks for helping out!

      Bram

  • Nov 13, 2018 at 10:37 AM

    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

    Add comment
    10|10000 characters needed characters exceeded

    • 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

  • Nov 14, 2018 at 03:23 AM

    Hello Bram,

    Could you please let me know the sender adapter you are using in your IFlow.

    Regards,

    Sriprasad Shivaram Bhat

    Add comment
    10|10000 characters needed characters exceeded

  • Nov 16, 2018 at 01:27 AM

    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.

    Add comment
    10|10000 characters needed characters exceeded

    • 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.