Skip to Content

Manage Message Processing in Case of Errors

test
0 %
Manage Message Processing in Case of Errors
Details

Manage Message Processing in Case of Errors

2019-12-17
Handle the message execution in case of errors.

You will learn

  • How to induce an artificial error or exception in your message pipeline
  • How to handle exceptions through Exception Sub-process
  • How to use different end events to manage errors
  • What is a send step

In this exercise, we will induce an artificial exception situation via a script.
An Exception Sub-process will be added to handle the artificial exception.
We will also play with the different End Events to see how they differ.


Step 1: Induce artificial exception

Let us induce an artificial error in the integration flow. We shall use the script step for the same.

  1. Add a script step:

    • Click on the design palette.
    • Choose Message Transformers.
    • Choose Script.
    • Choose Groovy Script.
    • Drag it on to the execution pipeline before the Message Mapping step.
    • Click the Script step and choose Create (+) from the list of speed buttons.Add script
    • Add the following code to the script’s processData method:

      def Message processData(Message message)
      {
          throw new Exception();
      }
      
      Exception Script
    • Click Ok.

  2. Save, deploy and execute the integration flow.

    • Go to the Monitoring view and look for an entry for the message just processed. The status of the message should be Failed – this indicates that an exception was thrown.

      Error View

    The Error Details section gives more information about the exception.

    • To get additional information about the exception, scroll down to the logs section (or click on the Logs tab) and click Info.

    Error Details

    A graphical viewer opens up and provides a visual representation of the exception location on the message execution pipeline.

    As the graphical viewer shows, the exception is caused by the Script step.

Log on to answer question
Step 2: Add Exception Sub-process to handle exception

Let us now add an Exception Sub-process to catch the exception and handle it.

  1. Add a Exception Sub-process to the Integration Flow:

    • Click on the design palette.

    • Choose Process.

    • Choose Exception Subprocess.

      Choose Exception SubProcess
    • Drag it within the Integration Flow.

      Add Exception SubProcessException SubProcess
  2. Save, deploy and execute the integration flow.

    • Go to the Monitoring view and look for an entry for the message just processed. The status of the message should be Completed – this indicates that the exception thrown by the script step is caught by the Exception Subprocess.

    Error View With Exception SubProcess

Log on to answer question
Step 3: Send mail to intimate about exception

You can configure additional actions in the Exception Sub-process that you would like to perform in case of an exception. In the exercise below, we intimate a systems manager about the exception via an email and ask him to resend the request if he likes us to reprocess.

  1. Add a mail receiver

    • Add a receiver to the canvas and connect it to the End Message in the Exception Sub-process.

    • Choose a mail adapter:

    Add Receiver
    • Copy the mail channel configuration:

      • Click any of the configured mail channel and choose the speed button for Copy Configuration.
      • Now select the newly created mail channel and choose the speed button for Paste Configuration. Click yes on the confirmation pop-up.

      Copy Mail Configuration

    • Click on the new mail channel, go to the Properties Sheet, go to the Connection tab and set the Subject field to An error occurred - Please resend:

      Exception Mail
  2. Save, deploy and execute the integration flow.

  3. Check your configured inbox. You should get the following email:

    Error email
Log on to answer question
Step 4: Switch to Error End Event

In the following exercise, we will change the End Message in the Exception Sub-process to an Error End Event.
The Error End Event will change the Message Execution status to Failed – similar to how it would have been if the exception was not handled in the Exception Sub-process.

Additionally you shall be able to perform additional tasks in case of an exception.

To summarize, with End Message, the Message Execution Status is set to Completed, where as with Error End Event, the status is set to Failed. In both cases, you can add additional processing in case of an error.

  1. Delete the End Message step in the Exception Sub-process and replace it with an Error End Event step:

    • Hover over the End Message step and click on the Delete speed button:

    Delete End

    • Click on the design palette.

    • Choose Events.

    • Choose Error End Event.

      Choose Error End Event
    • Drag it within the Exception Sub-process and connect it to the Error Start Event.

      Add Error End Event
  2. Save, deploy and execute the integration flow.

    • Go to the Monitoring view and look for an entry for the message just processed. The status of the message should be Failed - this message status indicates that the exception was raised, caught by the Exception Subprocess and finally set by the Error End Event.

      Error View With Error End Event
Log on to answer question
Step 5: Use send step to intimate an exception

In the following exercise, we shall be sending an email to the systems manager to intimate about the error in processing. You can model anything in the exception sub-process - similar to how you model the processing logic in the message execution pipeline. Here in the following steps, we are only sending an email.

Please note that you cannot connect the Error End Event to a receiver - Hence we will use an alternate way of sending an email.

  1. Add a send step to the message execution pipeline:

    • Click on the design palette.

    • Choose Call.

    • Choose External Call.

    • Click on Send.

      Choose Send Step
    • Drag it within the Exception Sub-process between the Error Start Event and the Error End Event.

      Add Send Step
  2. Add a mail receiver

    • Add a receiver to the canvas and connect it to the Send step in the Exception Sub-process.
    • Choose a mail adapter:

    Add Receiver

    • Copy the mail channel configuration:

      • Click on any of the configured mail channel and choose the speed button for Copy Configuration.
      • Now select the newly created mail channel and choose the speed button for Paste Configuration. Click yes on the confirmation pop-up.Copy Mail Configuration
    • Click on the new mail channel, go to the Properties Sheet, go to the Connection tab and set the Subject field to An error occurred - Please resend:

      Exception Mail

  3. Save, deploy and execute the integration flow.

  4. Check your configured inbox. You should get the following email:

    Error email

Log on to answer question
Step 6: Switch to Escalation End Event

In this exercise, we shall change the Error End Event to Escalation End Event and understand how the processing differs. As we shall see, the processing is unchanged - the Escalation End Event gives us a way to set the message execution status to a different value: Escalated.

  1. Delete the Error End Event step in the Exception Sub-process and replace it with an Escalation End Event step:

    • Hover over the Error End Event step and click on the Delete speed button:

    Delete End

    • Click on the design palette.

    • Choose Events.

    • Choose Escalation End Event.

      Choose Error End Event
    • Drag it within the Exception Sub-process and connect it to the Send step.

      Add Error End EventAdd Error End Event
  2. Save, deploy and execute the integration flow.

    • Go to the Monitoring view and look for an entry for the message just processed. The status of the message should be Escalated - this message status indicates that the exception was raised, caught by the Exception Sub-process and finally set by the Escalation End Event.

      Error View With Error End Event

      The Error Details section gives more information about the exception.

    • To get additional information about the exception, scroll down to the logs section (or click on the Logs tab) and click on Info.

    Error Details

    A graphical viewer opens up and provides a visual representation of the exception location on the message execution pipeline. The graphical viewer shows that the exception thrown by the Script step was caught in the Exception Sub-process. A mail was send and the message execution status was set to Escalated.

  3. The mail received is also exactly the same as with the Error End Event:

    Check your configured inbox. You should get the following email:

    Error email
What are the different message processing status in SAP Cloud Platform Integration?
×

Next Steps

Back to top