Explaining the Camel Data Model and Simple Expression Language

Objective

After completing this lesson, you will be able to Explain the Camel data model and simple expression language.

Camel Data Model and Simple Expression Language

In this Lesson, the Following Topics are Discussed:

  • The Camel Data Model.
  • Simple Expression Language.

The Camel Data Model

It is a container for the following elements:

  • Headers
  • Properties
  • Attachment
  • Body
  • Others

Here are the explanations:

Headers

Header data contains information related to the message, such as the message sender's address, and is automatically included in any subsequent HTTP call.

Properties

Additional data can be temporarily stored during message processing in the form of context objects.

Attachments

Contain optional data that is to be attached to the message.

Body

The payload to be transferred in a message is contained within the body. During message processing, an Exchange container is also available which can store additional data besides the message. This container is uniquely identified by an Exchange ID and can hold temporary data in the Properties area during message processing. The data stored in the Exchange container is available for the entire duration of the message exchange and is included in the container when the next processing step is called.

Manipulation of the Exchange Parameters

Exchange parameters, including the payload, are automatically set by incoming messages. However, these parameters can also be manually manipulated by reading and writing. Various methods are available for manipulating exchange parameters:

  • Use of the Content Modifier component.
  • Use the Groovy SDK
  • Use the JavaScript SDK
  • Use of PDF in Message Mapping
  • Use of XSLT Mapping
  • And even more

Set Exchange Parameters with Content Modifier Component

The Content Modifier element offers a graphical way to manipulate the Exchange parameters.

You can manipulate:

  • Header
  • Properties
  • Body

Set Exchange Parameters with Groovy SDK

The com.sap.gateway.ip.core.customdev.util.Message class offers methods to manipulate the parameters.

The same applies to JavaScript.

Simple Expression Language

The Simple Expression Language is used to parameterize Exchange Parameters. It also offers a number of Build In parameters, such as timestamps, error messages, and more. That means you have only a reading access to, for example, Exchange Parameters.

The general scheme is the ${ } placeholder containing a built-in variable or Exchange Parameters. In Cloud Integration, the ${ } placeholder can be inserted in, for example, the payload in a Content Modifier step, or applied in the Query Editor, adding dynamic values to an OData resource path.

The ${ } placeholder can also be combined with operators to produce boolean expressions, which you can then use as conditions in Routers, Filters, and more integration flow components.

Samples:

Code Snippet
Copy code
Switch to dark mode
1234
${property.MyNumericProperty} > 0 ${property.MyStringProperty} contains ‚test‘ property.ProductCoderegex‚[a−z]5\d3‘ ${date:now:dd-MM-yyyy HH:mm}

Specials Within Daily Business

The Message Body
${in.body}
Properties
${property.}
Message Headers
${header.}

The Simple Expression Language can be Used:

  • In Scripting with Groovy or JavaScript.
  • Within some integration flow components like Router, Content Modifier, and Message Mapping as user defined functions.
  • In XSLT Mappings.
  • In some adapters for querying.

Summary

The Camel Data Model is used to manage temporary data during processing in the individual integration flow components. This data model includes not only the payload (body) but also properties and header data, which are automatically included in an HTTP call.

The Exchange container is passed from the predecessor to the next processing step with each processing step. Exchange Parameters are set automatically, for instance when a message is received, and manually through components like the Content Modifier or the Groovy SDK, among others. The Camel Data Model manages the temporary data during processing, which includes the payload (body), properties, and header data. Header data is automatically included in an HTTP call.

Accessing the Exchange Parameters for reading is done through the Simple Expression Language, which not only includes built-in parameters but also allows for modeling complex regex expressions.

Create a Content Modifier with Sample Data as Payload (XML)

Business Scenario

To facilitate development, the list of Product IDs is initially provided locally, but you want to expand your integration process further.

Task Flow

In this exercise, you will perform the following tasks:

  1. Log on to the integration flow DelayedDelivery_Process.
  2. Place and configure a Content Modifier component.
  3. Save as version, deploy, and debug your integration process.

Prerequisites

The step of creating a timer event instead of the message start event has been completed.

Outcome After This Exercise

A Content Modifier with sample data as payload is provided for use.

What do you Learn Within This Exercise?

  • Learn to use and configure a Content Modifier.
  • Learn to trace your process.

Exercise Options

To carry out this exercise, you can choose from the following options:

  1. Live Environment: Using the instructions provided below, you can perform the steps in your SAP BTP account.
  2. Platform Simulation: Follow the step-by-step instructions within the simulation.
  3. Side-by-side: Follow the step-by-step instructions within the simulation and perform the steps in your SAP BTP account simultaneously.

Note

We strongly recommend to perform the steps in the live environment.

Task 1: Log on to the integration flow DelayedDelivery_Process

Steps

  1. Log on to the integration flow DelayedDelivery_Process via Integration Suite.

    1. Navigate within the Integration Suite Welcome page to DesignIntegrations and APIsDelayedDelivery_Package_randomNumberArtifactsDelayedDelivery_Process.

    2. Following the status after the last exercise step.

    3. Check, that the integration flow is in the editing status.

Task 2: Place and Configure a Content Modifier Component

Steps

  1. Place a TransformationContent Modifier component after the Start Timer 1 event.

    1. Place a Content Modifier component, as shown at the beginning.

    2. The result is a placed Content Modifier component.

  2. Configure the Content Modifier component.

    1. Call the configuration bar of the Content Modifier component with a double-click on the component.

    2. Choose the General tab and enter the following name.

      Field NameInput
      NameModify_setPayload
    3. Switch to the Message Body tab and enter the following SOAP payload.

      Code Snippet
      Copy code
      Switch to dark mode
      12345678910111213141516
      <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"> <soapenv:Header/> <soapenv:Body> <List> <Product> <ProductID>HT-1000</ProductID> </Product> <Product> <ProductID>HT-1020</ProductID> </Product> <Product> <ProductID>HT-1035</ProductID> </Product> </List> </soapenv:Body> </soapenv:Envelope>
    4. The requested products with their product IDs must already exist in the database. You may want to test this beforehand.

    5. To ensure that the ProductIDs used really return data, you can check with API beforehand. For example: https://sapes5.sapdevcenter.com/sap/opu/odata/iwbep/GWSAMPLE_BASIC/ProductSet('HT-1000')

      Note

      Be careful while copying the URLs. Ensure that there are single quotes in the URL and not apostrophes.

Task 3: Save as Version, Deploy, and Debug Your Integration Process

Steps

  1. Save as version and deploy your integration flow.

    1. As described in the last step, save as version, and deploy.

    2. After successfully deployed.

  2. Set the log level to debug.

    1. Go to MonitorIntegrations and APIsManage Integration Content from your Integration Flow configuration bar.

    2. Change the Log ConfigurationLog Level to Trace. With trace level you will see the payload.

    3. Switch to the browser tab where your integration flow is open and initiate the deployment process to start the debbuging.

      Note that the modified log level will only be applicable from the next instance of the deployed process. In this particular case, it will be effective immediately after deployment.

    4. From the deployed integration flow, directly go back to the current MonitorIntegrations and APIsManage Integration Content.

    5. A new browser tab opens, displaying the current instance of the MonitorIntegrations and APIsManage Integration Content.

    6. Choose the Monitor Message Processing link.

    7. Select the message with the status Completed. Then, in the detailed view of the message that appears on the right, choose the Log Level link.

    8. You are in the Trace view of your monitor:

  3. Explore the trace capabilities.

    1. On No. 1, you will see the steps.

    2. On No. 2, you will see the Integration Flow Model – corresponding with the tab, Integration Flow Model.

    3. On No. 3, you will see the log content of the step.

    4. On No. 4, you will see the payload.

    5. Choose the step End (No. 1). You will see that the corresponding part of the Integration Flow Model is also marked.

    6. Choose the Log Content tab (No. 3). You see the log entries for this step

    7. Choose the Message Content tab (No. 4).

    8. Choose Message before StepPayload to see the Payload as a result of the last step – here Modify_setPayload.

Log in to track your progress & complete quizzes