Integration with Split

Diagram

source code example split

Components and EIPs

Components EIPs

REST

From

HTTPS

ToD

Unmarshal

Split

Choice

Check the description of each component and EIP.

Description

Below is the description of the executed steps:

  • The flow begins with a GET request to the /startflow endpoint.

- from:
    Description: REST endpoint that triggers the flow
    uri: rest:get:/startflow
  • Then, the flow makes another GET request to an endpoint that returns a list of items.

steps:
  - toD:
      uri: https://example.com/api/list
      parameters:
        bridgeEndpoint: true
        httpMethod: GET
  • The response from the GET request is treated as JSON and is deserialized using the Jackson library. This allows the flow to handle the data as objects rather than just plain text.

- unmarshal:
    json:
      library: Jackson
  • The next step splits the JSON response (presumably a list) so that each item can be processed individually. The expression ${body} refers to the content of the response that was deserialized in the previous step.

- split:
    expression:
      simple:
        expression: ${body}
steps:
  - choice:
      when:
        - expression:
            simple: "${body[value] > 10}"
          steps:
            - toD:
                uri: https://example.com/api/true-endpoint
                parameters:
                  bridgeEndpoint: true
                  httpMethod: POST
otherwise:
  steps:
    - toD:
        uri: https://example.com/api/false-endpoint
        parameters:
          bridgeEndpoint: true
          httpMethod: POST

Flow Script

Below is the full script of the described integration flow:

- from:
    Description: REST endpoint that starts the flow
    uri: rest:get:/startflow  # Endpoint that starts the flow
    steps:
      - toD:
          uri: https://example.com/api/list  # GET request to retrieve the list of items
          parameters:
            bridgeEndpoint: true
            httpMethod: GET  # Defining the HTTP method as GET
      - unmarshal:
          json:
            library: Jackson  # Using the Jackson library to deserialize the JSON response
      - split:
          expression:
            simple:
              expression: ${body}  # Splitting the response (assuming it's a list) to iterate over the items
          steps:
            - choice:
                when:
                  - expression:
                      simple: "${body[value] > 10}"  # Condition to check if the 'value' field is greater than 10
                    steps:
                      - toD:
                          uri: https://example.com/api/true-endpoint  # Endpoint to be called if the condition is true
                          parameters:
                            bridgeEndpoint: true
                            httpMethod: POST  # HTTP POST method
                otherwise:
                  steps:
                    - toD:
                        uri: https://example.com/api/false-endpoint  # Endpoint to be called if the condition is false
                        parameters:
                          bridgeEndpoint: true
                          httpMethod: POST  # HTTP POST method
Thanks for your feedback!
EDIT

Share your suggestions with us!
Click here and then [+ Submit idea]